一、總結
- inner join
缺省,就是join;結果為兩張表的交集。
笛卡爾積后,篩選出滿足ON條件的 - outer join
又分為left join, right join, full join
以left join為例,迪卡爾積篩選出滿足ON條件的,再以左側(cè)表為基本,將右邊表不滿足ON條件的,補NULL
當右表會有多條記錄匹配左表時,那左表的相應記錄就會出現(xiàn)多次 - cross join
產(chǎn)生笛卡爾積,實際中很少用它
二、數(shù)據(jù)例子
users表:

image.png

image.png
以下命令的結果截圖展示:
-
SELECT * from users join message on users.userId=message.userId
image.png -
SELECT * from users left join message on users.userId=message.userId
image.png

