数据库表这样返回计数0与MySQL组由
============================
= suburb_id | value
= 1 | 2
= 1 | 3
= 2 | 4
= 3 | 5
查询
SELECT COUNT(suburb_id) AS total, suburb_id
FROM suburbs
where suburb_id IN (1,2,3,4)
GROUP BY suburb_id
然而,当我运行此查询,它并没有给COUNT(suburb_id)= 0时suburb_id = 0 因为在郊区表,没有suburb_id 4,我想这个查询为suburb_id = 4返回0,像
============================
= total | suburb_id
= 2 | 1
= 1 | 2
= 1 | 3
= 0 | 4
你是否有另一张桌子,提供所有郊区的信息?或者是surburb 4 Sir Not-In-In-This-Database? – Powerlord 2010-08-30 14:06:50