SELECT a.*, UNIX_TIMESTAMP(a.createdon) AS timestamp,
				COUNT(*) AS piccount, p.adid AS haspics, scat.subcatname AS subcatname, scat.catid as catid, cat.catname as catname
			FROM xzclf_ads a
				INNER JOIN xzclf_cities ct ON a.cityid = ct.cityid
				INNER JOIN xzclf_subcats scat ON a.subcatid = scat.subcatid
				INNER JOIN xzclf_cats cat ON scat.catid = cat.catid
				LEFT OUTER JOIN xzclf_adxfields axf ON a.adid = axf.adid
				LEFT OUTER JOIN xzclf_adpics p ON a.adid = p.adid AND p.isevent = '0'
			WHERE scat.catid = 7
				AND a.enabled = '1' AND a.verified = '1' AND a.expireson >= NOW()
				AND a.cityid = 13
			GROUP BY a.adid
			ORDER BY a.createdon DESC
			LIMIT 20Got error 28 from storage engine