例如,表
category_description
name | category_id | nav_id
History | 62 | 1
Romance | 61 | 1
mysql | 59 | 1
mssql | 60 | 1
然后
product_to_category
具有以下行,
product_id | category_id
55 | 62
54 | 62
select name,count(a.category_id) from category_description a,
product_to_category b
where a.category_id = b.category_id group by name;
我得到以下结果
+---------+----------------------+
| name | count(a.category_id) |
+---------+----------------------+
| History | 2 |
+---------+----------------------+
但是我试图计算空数据,例如除了以下输出之外
+---------+----------------------+
| name | count(a.category_id) |
+---------+----------------------+
| History | 2|
| mysql | 0|
| mssql | 0|
|Romance | 0|
+---------+----------------------+