黄东旭解析 TiDB 的核心优势
748
2023-05-09
一张图看懂SQL的各种Join用法
下图展示了 LEFT JOIN、RIGHT JOIN、INNER JOIN、OUTER JOIN 相关的 7 种用法。
具体分解如下:
1、INNER JOIN(内连接)
SELECT FROM Table_A AINNER JOIN Table_B BON A.Key = B.Key
2、LEFT JOIN(左连接)
SELECT FROM Table_A ALEFT JOIN Table_B BON A.Key = B.Key
3、RIGHT JOIN(右连接)
SELECT FROM Table_A ARIGHT JOIN Table_B BON A.Key = B.Key
4、OUTER JOIN(外连接)
SELECT FROM Table_A AFULL OUTER JOIN Table_B BON A.Key = B.Key
5、LEFT JOIN EXCLUDING INNER JOIN(左连接-内连接)
SELECT FROM Table_A ALEFT JOIN Table_B BON A.Key = B.KeyWHERE B.Key IS NULL
6.RIGHT JOIN EXCLUDING INNER JOIN(右连接-内连接)
SELECT FROM Table_A ARIGHT JOIN Table_B BON A.Key = B.KeyWHERE A.Key IS NULL
7、OUTER JOIN EXCLUDING INNER JOIN(外连接-内连接)
SELECT FROM Table_A AFULL OUTER JOIN Table_B BON A.Key = B.KeyWHERE A.Key IS NULL OR B.Key IS NULL
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。