了解数据库 SELECT 语句的执行顺序对我们编写正确、高效的查询语句有极大的帮助。各数据库类型并不完全一致,以MySql数据库为例,其执行顺序是:
FROM
ON
JOIN
WHERE
GROUP BY
WITH ROLLUP
HAVING
SELECT
DISTINCT
ORDER BY
LIMIT
附图:
了解数据库 SELECT 语句的执行顺序对我们编写正确、高效的查询语句有极大的帮助。各数据库类型并不完全一致,以MySql数据库为例,其执行顺序是:
FROM
ON
JOIN
WHERE
GROUP BY
WITH ROLLUP
HAVING
SELECT
DISTINCT
ORDER BY
LIMIT
附图: