The strange problem of mysql leftjoin

SELECT tg.id,tg.name
FROM trd_goods tg LEFT JOIN trd_goods_tag_relation tgt ON tg. id = tgt. goods_id

this is my sql statement, if 50 pieces of data on the left and 100 pieces of data on the right, it is an one-to-many relationship. If I have always understood that left join takes the left table as the benchmark, the last data will only be 50 pieces at most, and the right table will randomly match an association. But the result in reality is 100 pieces of data. I don"t understand why the gods gave me popular science

.
Mar.23,2021

your understanding of the left join is wrong, and the left join will match all the data that meets the conditions. If trd_goods has a record in trd_goods_tag_relation that does not match the data, it will still generate a record, but the field in the query trd_goods_tag_relation is null , which is dominated by the table on the left.


the result returned by the left join is the record in the left table, so the join fields in the right table are equal, so the minimum number of returned results is 50, not the most


.

your understanding is wrong!
take the left connection as an example:

 : 
Menu