Order of Clause Execution
Learn Order of Clause Execution (SELECT Queries, MySQL) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Introduction SQL is written in one order but executed in another. Logical order: FROM / JOIN then WHERE then GROUP BY then HAVING then window functions, SELECT (with DISTINCT), then ORDER BY , then LIMIT . Knowing this explains which names are visible where.