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 (9701607,9701515,9701391,9701271,9701257,9699823,9698878,9698712,9698701,9698699,9698300,9697681,9696606,9696498,9696490,9696278,9695410,9695409,9695408,9695403,9691534,9691483,9691036,9690847,9690739,9690697,9690694,9690589,9690580,9690154,9690148,9690067,9689965,9689962,9689482,9689452,9689038,9687875,9687623,9687524,9687437,9687398,9687383,9687275,9687083,9684981,9684668,9684347,9683858,9683852,9683846,9683543,9683432,9683324,9683219,9683204,9683129,9682859,9682856,9682649,9682643,9682514,9682511,9682472,9682268,9682265,9682262,9681504,9681303,9681276,9681141,9681018,9680955,9680946,9680736,9680289,9680286,9680280,9680277,9680271,9680268,9680265,9680262,9680259,9680250,9680247,9680244,9680241,9680238,9680235,9680232,9680229,9680226,9680220,9680217,9680214,9680211,9680208,9680205,9680172) GROUP BY a.adid LIMIT 30