SELECT statement Definition
A complete SELECT statement contains several optional clauses. The SELECT statement is defined as follows:
<SELECT clause> [<FROM clause>] [<WHERE clause>] [<group by clause>] [<HAVING clause>] [<order by clause>] [<LIMIT clause >]
The SELECT clause is required. Other clauses, such as the WHERE clause and group by clause, are optional.
In a SELECT statement, the order of clauses is fixed. For example, the group by clause is not located before the WHERE clause.
SELECT statement execution sequence
The execution sequence of the SELECT statement substatements is different from that of the SELECT statement substatements. Therefore, the substatements are executed in the following order instead of starting from the SELECT clause:
Start> FROM clause> WHERE clause> group by clause> HAVING clause> order by clause> SELECT clause> LIMIT clause> final result
After each clause is executed, an intermediate result is generated for the subsequent clause. If no clause exists, skip