龙空技术网

一张图看懂 SQL 的各种 join 用法

Java架构师日记 61

前言:

此时各位老铁们对“java解析sql from join”都比较关心,大家都想要了解一些“java解析sql from join”的相关知识。那么小编同时在网上网罗了一些有关“java解析sql from join””的相关内容,希望同学们能喜欢,同学们一起来学习一下吧!

作者 | C.L. Moffatt

来源 | codeproject

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

具体分解如下:

1.INNER JOIN(内连接)

SELECT <select_list> FROM Table_A AINNER JOIN Table_B BON A.Key = B.Key

2.LEFT JOIN(左连接)

SELECT <select_list>FROM Table_A ALEFT JOIN Table_B BON A.Key = B.Key

3.RIGHT JOIN(右连接)

SELECT <select_list>FROM Table_A ARIGHT JOIN Table_B BON A.Key = B.Key

4.OUTER JOIN(外连接)

SELECT <select_list>FROM Table_A AFULL OUTER JOIN Table_B BON A.Key = B.Key

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

SELECT <select_list> FROM Table_A ALEFT JOIN Table_B BON A.Key = B.KeyWHERE B.Key IS NULL

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

SELECT <select_list>FROM Table_A ARIGHT JOIN Table_B BON A.Key = B.KeyWHERE A.Key IS NULL

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

SELECT <select_list>FROM Table_A AFULL OUTER JOIN Table_B BON A.Key = B.KeyWHERE A.Key IS NULL OR B.Key IS NULL

(完)

ps:最近公众号学习资料有更新。

标签: #java解析sql from join