SELECT a.adid, a.adtitle, a.thumbfile, pics.picfile, pics.cdn, 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 AND pics.cdn<>'cdn4') LEFT JOIN xzclf_location loc ON (LOWER(a.area) = LOWER(loc.locationname) AND loc.stateid = a.cityid) WHERE a.adid IN (10388429,10365896,10348253,10343089,10341623,10338215,10338042,10335924,10335032,10335026,10335021,10332484,10332436,10329633,10315757,10308359,10298819,10266373,10266370,10266365,10247445,10154405,10133172,10133079,10107138,10107137,10107130,10096268,10096266,10096207,10096082,10096001,10095921,10095918,10095843,10095754,10094856,10094387,10071672,10064012,10042432,10042387,10026914,10021080,10021034,10020980,10006935,9997438,9991961,9991950,9991873,9991735,9991506,9990302,9990158,9988670,9988608,9985828,9985201,9983737,9983419,9982321,9982166,9980944,9980907,9979205,9976717,9975701,9974445,9972532,9970090,9969193,9969184,9967923,9967919,9966795,9966268,9966258,9966253,9966131,9966125,9966121,9964771,9957713,9957710,9957641,9957332,9957098,9956996,9956978,9956969,9956876,9956780,9956777,9956747,9956723,9956684,9956618,9956603,9956579) GROUP BY a.adid LIMIT 30