The clauses in a SELECT
have a specific order:
SELECT ... FROM ... WHERE ... GROUP BY ... HAVING ...
ORDER BY ... -- goes here
LIMIT ... OFFSET ...;
( SELECT ... ) UNION ( SELECT ... ) ORDER BY ... -- for ordering the result of the UNION.
SELECT ... GROUP_CONCAT(DISTINCT x ORDER BY ... SEPARATOR ...) ...
ALTER TABLE ... ORDER BY ... -- probably useful only for MyISAM; not for InnoDB