作者:大飞5678 | 来源:互联网 | 2023-09-07 17:33
Ihaveasqlstatementlikethis(usingmysql5.5.15):我有这样的sql语句(使用mysql5.5.15):selectglobal_i
I have a sql statement like this (using mysql 5.5.15):
我有这样的sql语句(使用mysql 5.5.15):
select global_id, count(id) as group_count
from globals_lists
group by global_id
order by group_count desc;
and would like to modify it to support a subset with an in statement like this:
并希望修改它以支持具有in语句的子集,如下所示:
select global_id, count(id) as group_count
from globals_lists
where global_id in (3,4,5,6)
group by global_id
order by group_count desc;
I'll get as a result:
我会得到一个结果:
global_id group_count
3 15
5 12
but would like
但是想
global_id group_count
3 15
5 12
4 0
6 0
Is this possible? I tried a couple of having clauses but couldn't seem to get it working.
这可能吗?我尝试了几个条款,但似乎无法使它工作。
3 个解决方案