我们编写的语句格式如下:
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 >
MySQL的执行顺序如下:
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>
虽然,我们写的SELECT
语句在前,但是在MySQL的执行顺序中,首先执行的FROM
语句。
图形方式展示如下: