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语句

posted @ 2020-08-19 22:02  寂静音无  阅读(123)  评论(0)    收藏  举报