The difference between adding conditions after on in mysql left join and adding conditions in where

Several knowledge points about where and on conditions in
left join : 1. Multi-table left join will generate a temporary table and return it to the user
2. Where condition is to filter out the last temporary table generated Records that do not meet the where conditions are filtered out if they are truly non-compliant.
3. The on condition is to perform conditional filtering on the right table of the left join, but it still returns all rows of the left table, and the complement in the right table is NULL.
4. If there are restrictions on the left table in the on condition, regardless of whether the condition is true or false , Still returns all rows of the left table, but will affect the matching value of the right table. That is to say, the restriction condition of the left table in on only affects the matching content of the right table, and does not affect the number of rows returned.
Conclusion: 1. The
left table is restricted in the
where condition and cannot be placed after on. 2. The right table is restricted in the where condition. After on, there will be a difference in the number of data rows, which is more than the original number of rows.

Guess you like

Origin blog.csdn.net/weixin_39472101/article/details/114532862