Select -- from -- where -- group by -- having -- order by is ordered sequentially. The difference between where and having
1. the keywords used in the query mainly include six, and their order is
Select -- from -- where -- group by -- having -- order
Select and from are mandatory, and other keywords are optional. The execution sequence of these six keywords
The writing sequence is not the same as that of the SQL statement, but is executed in the following order.
From -- where -- group by -- having -- select -- order,
From: The data table from which data is to be retrieved.
Where: Filter table data Conditions
Group by: How to group the data filtered out above
Having: filtering conditions for the data already grouped above
Select: Check the column in The result set or the calculation result of the column.
Order by: in which order to view the returned data
2. Table association after from is parsed from right to left
The resolution sequence of the where condition is bottom-up.
That is to say, when writing SQL files, try to put tables with a large amount of data on the rightmost side for association,
Put the conditions that can filter out a large amount of data at the bottom of the where statement.