MySQL执行顺序

一、SQL语句执行顺序

(1) FROM  <left table>

(2) ON <join_condition>

(3) <join_type> JOIN <right_talbe>

(4) WHERE <where_condition>

(5) GROUP BY <group_by_list>

(6) HAVING <having_condition>

(7) SELECT

(8) DISTINCT <select_list>

(9) ORDER BY <order_by_condition>

(10) LIMIT <limit_number>

1、from 对查询指定的表计算笛卡尔积

2、on 按照 join_condition 过滤数据

3、join 添加关联外部表数据

4、where 按照where_condition过滤数据

5、group by 进行分组操作

6、having 按照having_condition过滤数据

7、select 选择指定的列

8、distinct 指定列去重

9、order by 按照order_by_condition排序

10、limit 取出指定记录量

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容