As shown below:
from Table
where condition
group by field
Forming Virtual Tables and Fields, Aggregation and Field Addition
having Filtering data
distinct De-duplication
order by field asc,desc
limit Limit the number of entries
select Listing records
First load the data from the table into memory according to the where constraint, so the condition of where acts before the data, and then group them according to the fields to form a virtual table containing the fields in memory.
If there is an aggregation function at this time, then the aggregation function is first implemented, and the aggregation function field is also added to the virtual table, followed by having records filtering, filtering is completed after the data is de-emphasized, sorting, limiting and other operations after the display.
Additional knowledge:mysql where condition AND is executed in order from left to right
Before doing the function, the three conditions through the md5 encryption to get a string field unique_key, set this field as a unique index, I hope that the query through the unique index to query, do not have to be divided into three conditions were queried, while using the replace method to ensure that the same three conditions to update the data, then the database will only have a record.
Later found that the list query must be open to these three conditions, so had to put the unique_key to where conditions and the leftmost, through the unique_key filtered out the efficiency will not be bad.
All aspects of mysql optimization should be taken into account when writing.
This mySQL keyword execution priority explanation is all that I have shared with you.