SELECT b.id,b.cid,b.name,t.type FROM shbooks b LEFT JOIN shtype t ON t.id = b.cid;
SELECT b.id,b.cid,b.name,t.type FROM shbooks b LEFT OUTER JOIN shtype t ON t.id = b.cid;
不加OUTER的时候,我完全能理解,把表1在表2对应的类名显示出来,
但是加上 OUTER后,我看到结果还是一模一样,用什么例子可以理解加和不加的区别呢?
LEFT JOIN and LEFT OUTER JOIN are the same, except that usually when we write SQL statements, we omit OUTER. This can be understood like inner joins. When we write inner joins, we usually omit INNER and write JOIN directly
Multiple table links are available
Inner join (JOIN or INNER JOIN)
Outer join
Left JOIN or LEFT OUTER JOIN
Right JOIN or RIGHT OUTER JOIN
A complete outer join is to connect the left join and right join statements together through the key UNION
Cross join (CROSS JOIN), this will involve the Cartesian product. My personal understanding of the Cartesian product is the cross combination of two tables. So the set result obtained is the queried records that meet the conditions in table A * the records that meet the conditions in table B.
These two should be the same.
Left join is the abbreviation of left outer join.
You can use explain extended and show warnings to see the statements after database optimization and rewriting. The two SQLs are the same.