图解SQL的join用法 有更新!

2019-02-12
0 评论 91 浏览

  • 导读: 展示了 LEFT JOIN、RIGHT JOIN、INNER JOIN、OUTER JOIN 相关的 7 种用法。

www.codeproject.com/Articles/33052/Visual-Representation-of-SQL-Joins

INNER JOIN(内连接)

640webp

SELECT  __
FROM Table_A A
INNER  JOIN Table_B B
ON A.Key = B.Key

LEFT JOIN(左连接)

6401webp

SELECT  _
_FROM Table_A A
LEFT  JOIN Table_B B
ON A.Key = B**


OUTER JOIN(外连接)

6403webp

SELECT  _
_FROM Table_A A
FULL  OUTER  JOIN Table_B B
ON A.Key = B.Key


RIGHT JOIN(右连接)

6402webp


SELECT  _
_FROM Table_A A
RIGHT  JOIN Table_B B
ON A.Key = B.Key

LEFT JOIN EXCLUDING INNER JOIN(左连接-内连接)

6404webp

SELECT  __
FROM Table_A A
LEFT  JOIN Table_B B
ON A.Key = B.Key
WHERE B.Key  IS  NULL

RIGHT JOIN EXCLUDING INNER JOIN(右连接-内连接)

6405webp


SELECT  _
_FROM Table_A A
RIGHT  JOIN Table_B B
ON A.Key = B.Key
WHERE A.Key  IS  NULL

OUTER JOIN EXCLUDING INNER JOIN(外连接-内连接)

6406webp


SELECT  _
_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

评论
发表评论
validate
取消