MySQL-一条sql语句的执行顺序

手写:

SELECT DISTINCT <select_list>
FROM <left_table> 
<join_type> JOIN <right_table> 
ON <join_condition>
WHERE <where_condition>
GROUP BY <group_by_list>
HAVING <having_condition>
ORDER BY <order_by_condition>
LIMIT <limit_number>  

机读:

FROM <left_table>
ON <join_condition>
<join_type> JOIN <right_table>
WHERE <where_condition>
GROUP BY <group_by_list>
HAVING <having_condition>
SELECT DISTINCT <select_list>
ORDER BY <order_by_condition>
LIMIT <limit_number> 

from:需要从哪个数据表检索数据 
where:过滤表中数据的条件 
group by:如何将上面过滤出的数据分组 
having:对上面已经分组的数据进行过滤的条件 
select:查看结果集中的哪个列,或列的计算结果 
order by :按照什么样的顺序来查看返回的数据 

posted @ 2019-08-21 06:00  与君共舞  阅读(563)  评论(0编辑  收藏  举报