MySQL Заказ на выполнение запроса:

Order of execution SQL or MySql query Or Logical order of operations:

FROM, including JOINs
WHERE
GROUP BY
HAVING
WINDOW functions
SELECT
DISTINCT
UNION
ORDER BY
LIMIT and OFFSET
@CodeGrepperManu