where:是利用数据库本来存在的数据在查询,是在group by、having之前执行。

group by:是将本来就有的数据按照条件进行分组。

having:是将数据库没有的数据,可以理解为group by后的数据,再次进行条件判断查询,在group by后执行。

 

例如场景查询:按手机号分组查出权限种类数大于1的手机号

select count(distinct role),mobile from 表名 group by mobile having count(distinct role) > 1;

相关文章:

  • 2022-12-23
  • 2021-03-30
  • 2021-09-27
  • 2021-07-24
  • 2021-06-02
  • 2022-12-23
  • 2021-12-28
  • 2022-12-23
猜你喜欢
  • 2021-09-15
  • 2022-02-14
  • 2021-10-06
  • 2022-12-23
  • 2022-12-23
  • 2021-05-20
  • 2022-12-23
相关资源
相似解决方案