Source article: How the Executed IS A Query in MySQL?
When executing SQL Select query, the order of execution of SQL commands is as follows:
- FROM clause
- WHERE clause
- GROUP BY clause
- HAVING clause
- SELECT clause
- ORDER BY clause
However, HAVING and GROUP BY clause after the SELECT, depending on the order specified in the query.