從數(shù)學(xué)的角度看,是集合的操作卦尊。
比如有where語句的內(nèi)連接,相當(dāng)于取交集舌厨。
有的是 左連接 - 內(nèi)連接
當(dāng)然岂却,這一切的前提是笛卡爾積。
MySQL不支持OUTER JOIN(外連接)裙椭,最下面的一行左邊躏哩,但是有替代方案。
select * from table a A(A為別名)LEFT JOIN table b B on A.id=B.id
union
select * from table a A RIGHT JOIN table b B on A.id=B.id;
至于最下面一行右邊
select * from table a A(A為別名)LEFT JOIN table b B on A.id=B.id
where B.id is null
union
select * from table a A RIGHT JOIN table b B on A.id=B.id
where A.id is null;