1.条件查询 having:
- having和where很像都是用来做条件查询的
- 但是where是去数据库中查询符合条件的数据, 而having是去结果集中查询符合条件的数据
select * from stu where city='北京';
select * from stu having city='北京';
select name, age from stu where city='北京';
select name, age from stu having city='北京';
#Unknown column 'city' in 'having clause'
需求: select city from stu group by city;
需求: select city, avg(score) from stu group by city;
需求: select city, avg(score) as average from stu group by city;
需求: select city, avg(score) as average from stu group by city having average>=60;