What is the difference between on and where in MySQL query conditions
Today, I will talk to you about the difference between on and where in MySQL query conditions, which may not be understood by many people. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
MySQL statement execution order
Let's start with the concept that the order in which MySQL statements are executed is not in the order in which SQL statements are executed. Here is a sample SQL
SELECT DISTINCT
< select_list >FROM
< left_table > < join_type >JOIN
< right_table >ON
< join_condition >WHERE
< where_condition >GROUP BY
< group_by_list >HAVING
< having_condition >ORDER BY
< order_by_condition >LIMIT
< limit_number >The following is the order in which SQL is executed
FROM ON JOIN WHERE GROUP BY HAVING SELECT DISTINCT ORDER BY LIMIT
The role of LEFT JOIN
The difference of the result set is related not only to the priority of SQL, but also to LEFT JOIN.
When using left join, the conditions that follow on are valid only for the right table.
On is the condition used when generating a temporary table, and the row of the left table (table_name1) is returned regardless of whether the condition of on works or not.
Where is the condition used after the temporary table is generated, regardless of whether left join is used or not, as long as the condition is not true, filter it all.
After reading the above, do you have any further understanding of the difference between on and where in MySQL query conditions? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.