整张表的表结构:test表
使用select type,count(type) as total from test where remain>5 group by type;发现无法将total值为0的字段展示出来
截图:
接下来我们利用左右连接解决此问题:
命令:
select distinct type from test;
截图:
命令:
select type,count(type) as total from test where remain>5 group by type;
截图:
命令:
select type,count(type) as total from test where remain>5 group by type;
select * from (select distinct type from test) a
LEFT JOIN
(select type,count(type) as total from test where remain>5 group by type) b
on a.type=b.type;
截图:
完美的将此问题解决,是不是非常的nice?