Subquery classification
Divided into 4 types according to the number of rows and columns of the result set
Standard quantum query (the result set has only one row and one column)
Column subquery (the result set has only one column and multiple rows)
Row subquery (the result set has one row with many columns)
Table subquery (the result set is generally multiple rows and columns)
According to the different positions of the subquery in the main query
After select: only supports standard quantum query.
From behind: Support table subquery.
behind where or having: support standard quantum query (single column and single row), column subquery (single column and multiple rows), row subquery (multiple columns and multiple rows)
Behind exists (that is, related subqueries): table subqueries (multiple rows, multiple columns)
Mysql execution order
- from
- on
- join
- where
- group by
- having
- select
- distinct
- union
- order by
- limit