image
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>
乍一看SQL的解析执行顺序还是让我有点儿出乎意料。但仔细看发现还是很合理的
从哪些表获取数据,这些表中数据通过哪个字段对应,检索什么样的数据,如何进行分组,过滤组,选择排重数据,然后再进行排序限制取几条。
网友评论