SELECT a.adid, a.adtitle, a.thumbfile, pics.picfile, UNIX_TIMESTAMP(a.createdon) AS timestamp, scat.subcatname, loc.locationslug FROM xzclf_ads a INNER JOIN xzclf_subcats scat ON a.subcatid = scat.subcatid INNER JOIN xzclf_adpics pics ON a.adid = pics.adid LEFT JOIN xzclf_location loc ON (LOWER(a.area) = LOWER(loc.locationname) AND loc.stateid = a.cityid) WHERE a.adid IN (10145820,10145302,10145296,10145293,10145290,10145284,10145278,10145275,10145269,10145266,10145263,10145257,10145254,10145248,10145245,10145242,10145236,10145233,10145227,10145224,10145221,10145212,10145209,10145203,10145197,10145194,10145185,10145182,10145179,10145173,10145170,10145167,10145161,10145158,10145152,10145149,10145146,10145140,10145137,10145131,10145128,10145122,10145119,10145116,10145110,10145107,10145104,10145098,10145095,10145089,10145086,10145080,10145077,10145074,10145068,10145065,10145062,10145056,10145053,10145047,10145044,10145038,10145035,10145029,10145023,10145017,10145014,10145008,10145005,10144999,10144996,10144987,10144984,10144981,10144975,10144972,10144963,10144960,10144954,10144948,10144945,10144936,10144933,10144927,10144924,10144921,10144909,10144903,10144900,10144024,10144009,10144000,10143991,10143505,10143442,10143439,10143430,10143370,10143367,10143343) GROUP BY a.adid LIMIT 30