mysql分组查询和
分组
group by
必须出现where之后 order by之前
having
having子句过滤指定分组
过滤总数大于等于2的分组
select id,COUNT(*) as oders from classinfo group by id having count(*)>=2
select id,COUNT(*) as oders from classinfo where cid>=20 group by id having count(*)>=2
子查询
where in in() 括号中可以是结果集也就是in中可以使用select语句

浙公网安备 33010602011771号