wuxu

1.类型:

“baiWhere”是一个约束声明,在查询数据库du的结果返回之前对数据库中zhi的查询条件进行约束dao,即在结果返回之前起作用,且where后面不能使用“聚合函数”;

“Having”是一个过滤声明,所谓过滤是在查询数据库的结果返回之后进行过滤,即在结果返回之后起作用,并且having后面可以使用“聚合函数”。

 

 

2.使用的角度:

where后面之所以不能使用聚合函数是因为where的执行顺序在聚合函数之前,如下面这个sql语句:

select  sum(score) from student  group by student.sex where sum(student.age)>100;   X

having既然是对查出来的结果进行过滤,那么就不能对没有查出来的值使用having,如下面这个sql语句: 

select  student.id,student.name from student having student.score >90;X

分类:

技术点:

相关文章:

  • 2022-02-20
  • 2022-01-05
  • 2022-12-23
  • 2021-02-07
  • 2021-11-17
  • 2021-04-28
  • 2021-11-08
  • 2022-12-23
猜你喜欢
  • 2021-11-17
  • 2021-08-21
  • 2021-11-14
  • 2022-02-08
  • 2021-10-19
  • 2021-12-06
  • 2021-07-30
相关资源
相似解决方案