SQL statement SELECT statement Query order
- (7) SELECT
- (8) DISTINCT <select_list>
- (1) from <left_table>
- (3) <join_type> join <right_table>
- (2) on <join_condition>
- (4) WHERE <where_condition>
- (5) GROUP by <group_by_list>
- (6) having
- (9) ORDER by <order_by_condition>
- (Ten) LIMIT <limit_number>
One, executes the FROM
statement, the MySQL is executes from left to right, Oracle is executes from right to left, the SQL statement executes the procedure, will produce a virtual table, is used to save the SQL statement execution result (this is the key), Executing the FROM statement results in a virtual table called VT1 (vitual table 1), VT1 is generated from the Cartesian product
Second, the execution on to filter
Filter out non-conforming data according to the conditions on the back, parameter VT2
Iii. Types of execution links
Inner JOIN, left JOIN, right link, outer join outer link, full outer join connection
VT3 after execution
Iv. executing the conditions behind where
When using the Where condition, be aware that the group function cannot be used, and the alias of the field cannot be used in the condition
For example select City as C from T WHERE c= ' Shanghai '
V. Implementing GROUP BY
Vi. implementation of having a filter
HAVING
Clauses are GROUP BY
used in conjunction with clauses, which can be followed by the condition of the group function
VII. implementation of SELECT
Viii. execute DISTINCT, remove duplicate data
Ix. ORDER BY Statement execution
X. Executing paging statements
Transferred from: http://blog.csdn.net/u010833154/article/details/50696583
MySQL SQL statement Execution order