Ordem de execução de consulta do 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