要想面对一个新的开始,一个人必须有梦想、有希望、有对未来的憧憬。如果没有这些,就不叫新的开始,而叫逃亡。
下图展示了 LEFT JOIN、RIGHT JOIN、INNER JOIN、OUTER JOIN 相关的 7 种用法。
具体分解如下:
1.INNER JOIN(内连接)
SELECT
FROMTable_A A
INNERJOINTable_B B
ON A.Key = B.Key
2.LEFT JOIN(左连接)
SELECT
FROMTable_A A
LEFTJOINTable_B B
ON A.Key = B.Key
3.RIGHT JOIN(右连接)
SELECT
FROMTable_A A
RIGHTJOINTable_B B
ON A.Key = B.Key
4.OUTER JOIN(外连接)
SELECT
FROMTable_A A
FULLOUTERJOINTable_B B
ON A.Key = B.Key
5.LEFT JOIN EXCLUDING INNER JOIN(左连接-内连接)
SELECT
FROMTable_A A
LEFTJOINTable_B B
ON A.Key = B.Key
WHERE B.KeyISNULL
6.RIGHT JOIN EXCLUDING INNER JOIN(右连接-内连接)
SELECT
FROMTable_A A
RIGHTJOINTable_B B
ON A.Key = B.Key
WHERE A.KeyISNULL
7.OUTER JOIN EXCLUDING INNER JOIN(外连接-内连接)
SELECT
FROMTable_A A
FULLOUTERJOINTable_B B
ON A.Key = B.Key
WHERE A.KeyISNULLORB.KeyISNULL
网友评论