LEFT JOIN、RIGHT JOIN、INNER JOIN、OUTER JOIN 一张图看懂 SQL 7 种JOIN用法
LEFT JOIN、RIGHT JOIN、INNER JOIN、OUTER JOIN 相关的 7 种用法。
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 A FULL 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 A FULL OUTER JOIN Table_B BON A.Key = B.KeyWHERE A.Key IS NULL OR B.Key IS NULL
相关文章
- 小米 14U、OPPO X7U 和 vivo X100 U 该怎么选?
- iPhone 16 Pro即将震撼来袭,屏幕尺寸、性能、摄像头全面升级,你准备好了吗?
- 中国航空新篇章!国航、南航正式迎来首架国产C919飞机!
- oppo哪个系列的手机比较好?Find、Reno、K、A 等系列推荐
- 暴雨来袭,长沙多个网红打卡地紧急关闭!岳麓山、橘子洲还能“打卡”吗?
- 阿里要求各业务“有经营意识”、进一步明确投入重点
- “穷鬼三件套”——可乐、榨菜、方便面集体涨价,引发消费者关注。
- 科技春晚来袭,一半机器人、一半大模型,中国科技实力令人瞩目
- 华为Mate60、MateX5手机已通过OpenHarmony兼容性测评,还有全新TaiShan能效核在测试
- 博朗新3系3080s电动剃须刀:高效、舒适、便捷的剃须新选择