Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the difference between on and where in MySQL query conditions

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report