0

以下查询返回包含计数大于 0 的结果,即它忽略没有条目的记录om.memberid

SELECT id, organizationname, organizationwebsite, renewDate, COUNT( om.memberid ) 
FROM organization o, organizationmember om
WHERE om.organizationid = o.id
GROUP BY o.id

我可以得到count(om.memberid)0 的结果,即在om.memberid.

请为此建议我一个解决方案

4

1 回答 1

1

你可以使用LEFT JOIN.

SELECT o.id, o.organizationname, o.organizationwebsite, o.renewDate, COUNT( om.memberid ) 
FROM organization o
LEFT JOIN organizationmember om ON om.organizationid = o.id 
GROUP BY o.id
于 2012-06-06T08:42:11.327 回答