tft每日頭條

 > 生活

 > sql語句中join包含哪些方式

sql語句中join包含哪些方式

生活 更新时间:2025-01-08 19:44:18

下圖展示了 LEFT JOIN、RIGHT JOIN、INNER JOIN、OUTER JOIN 相關的 7 種用法。

sql語句中join包含哪些方式(一張圖看懂SQL的各種)1

具體分解如下:

1.INNER JOIN(内連接)

sql語句中join包含哪些方式(一張圖看懂SQL的各種)2

SELECT

FROM Table_A A

INNER JOIN Table_B B

ON A.Key = B.Key

2.LEFT JOIN(左連接)

sql語句中join包含哪些方式(一張圖看懂SQL的各種)3

SELECT

FROM Table_A A

LEFT JOIN Table_B B

ON A.Key = B.Key

3.RIGHT JOIN(右連接)

sql語句中join包含哪些方式(一張圖看懂SQL的各種)4

SELECT

FROM Table_A A

RIGHT JOIN Table_B B

ON A.Key = B.Key

4.OUTER JOIN(外連接)

sql語句中join包含哪些方式(一張圖看懂SQL的各種)5

SELECT

FROM Table_A A

FULL OUTER JOIN Table_B B

ON A.Key = B.Key

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

sql語句中join包含哪些方式(一張圖看懂SQL的各種)6

SELECT

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(右連接-内連接)

sql語句中join包含哪些方式(一張圖看懂SQL的各種)7

SELECT

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(外連接-内連接)

sql語句中join包含哪些方式(一張圖看懂SQL的各種)8

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

注:本文章僅限于交流使用,如有侵權請聯系删除

,

更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!

查看全部

相关生活资讯推荐

热门生活资讯推荐

网友关注

Copyright 2023-2025 - www.tftnews.com All Rights Reserved