查询语句的执行顺序

来源:互联网 发布:程序员真的每天很累吗 编辑:程序博客网 时间:2024/05/29 18:51

1  from  

2, join ..on

3,where,

4,group by 

5 having ,

6,select

7,distinct,

8,order by   

例如,查询平均工资高于8000的部门的最高和最低 工资

select   max(sal),min(sal),depto  from emp   group by depto   having avg(sal)   >8000

先 from  emp表,有关联 在关联(join..on) ,然后  where条件,接着 group  by, having,  select ,

原创粉丝点击