SELECT ds.*, ifnull(dsi.cnt,0) cnt from (SELECT * from zp_dogspot order by dogspot_id) ds left outer join (SELECT count( dogspot_id ) cnt, dogspot_id FROM `zp_dogspot_info` WHERE pet_id !=0 GROUP BY dogspot_id ) dsi on ds.dogspot_id = dsi.dogspot_id order by dogspot_id desc LIMIT 0 ,5DB Error, could not query the database MySQL Error: