下圖展示了 LEFT JOIN、RIGHT JOIN、INNER JOIN、OUTER JOIN 相關的 7 種用法。
具體分解如下:
1、INNER JOIN(内連接)
SELECT <select_list> FROM Table_A A INNER JOIN Table_B B ON A.Key = B.Key
2、LEFT JOIN(左連接)
SELECT <select_list> FROM Table_A A LEFT JOIN Table_B B ON A.Key = B.Key
3、RIGHT JOIN(右連接)
SELECT <select_list> FROM Table_A A RIGHT JOIN Table_B B ON A.Key = B.Key
4、OUTER JOIN(外連接)
SELECT <select_list> FROM Table_A A FULL OUTER JOIN Table_B B ON A.Key = B.Key
5、LEFT JOIN EXCLUDING INNER JOIN(左連接-内連接)
SELECT <select_list> FROM Table_A A LEFT JOIN Table_B B ON A.Key = B.Key WHERE B.Key IS NULL
6.RIGHT JOIN EXCLUDING INNER JOIN(右連接-内連接)
SELECT <select_list> FROM Table_A A RIGHT JOIN Table_B B ON A.Key = B.Key WHERE A.Key IS NULL
7、OUTER JOIN EXCLUDING INNER JOIN(外連接-内連接)
SELECT <select_list> FROM Table_A A FULL OUTER JOIN Table_B B ON A.Key = B.Key WHERE A.Key IS NULL OR B.Key IS NULL
●編号638,輸入編号直達本文
●輸入m獲取文章目錄
來源網絡,侵權删除
,更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!