码迷,mamicode.com
首页 > 数据库 > 详细

MySQL的having子句

时间:2017-10-15 19:26:04      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:查询   语句   rom   分析   城市名称   sel   color   span   ffffff   

1.定义:having子句对分组的结果集进行进一步的筛选

2.语法:select 字段列表 from 表名称 [where 子句][gruop by 子句] [having 子句];

3.举例:查询出同一城市的平均工资大于1000的城市名称以及工资

  分析:先查询出同一城市的平均工资

  语句:select city,avg(salary) from student group by city having avg(salary)>=10000;

注解:

1.having子句位于group by之后

2.having相当于where进行条件判断

  比如:select * from student where id<10;等价于:select * from student having id<10;

 

MySQL的having子句

标签:查询   语句   rom   分析   城市名称   sel   color   span   ffffff   

原文地址:http://www.cnblogs.com/Worssmagee1002/p/7672907.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!