【62期】解释一下MySQL中内连接,外连接等的区别(MySQL面试第五弹)
程序员文章站
2022-04-26 15:19:10
...
程序员的成长之路
互联网/程序员/技术/资料共享
阅读本文大概需要 2 分钟。
来自:www.codeproject.com/Articles/33052
下图展示了 LEFT JOIN、RIGHT JOIN、INNER JOIN、OUTER JOIN 相关的 7 种用法。
具体分解如下:
1.INNER JOIN(内连接)
SELECT <select_list>
FROM Table_A A
INNER JOIN Table_B B
ON A.Key = B.Key
2.LEFT JOIN(左连接)
SELECT <select_list>
FROM Table_A A
LEFT JOIN Table_B B
ON A.Key = B.Key
3.RIGHT JOIN(右连接)
SELECT <select_list>
FROM Table_A A
RIGHT JOIN Table_B B
ON A.Key = B.Key
4.OUTER JOIN(外连接)
SELECT <select_list>
FROM Table_A A
FULL OUTER JOIN Table_B B
ON A.Key = B.Key
5.LEFT JOIN EXCLUDING INNER JOIN(左连接-内连接)
SELECT <select_list>
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(右连接-内连接)
SELECT <select_list>
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(外连接-内连接)
SELECT <select_list>
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
<END>
推荐阅读:
【61期】MySQL行锁和表锁的含义及区别(MySQL面试第四弹)
【60期】事务隔离级别中的可重复读能防幻读吗?(MySQL面试第三弹)
【59期】MySQL索引是如何提高查询效率的呢?(MySQL面试第二弹)
5T技术资源大放送!包括但不限于:C/C++,Linux,Python,Java,PHP,人工智能,单片机,树莓派,等等。在公众号内回复「2048」,即可免费获取!!
微信扫描二维码,关注我的公众号
朕已阅
下一篇: git fetch学习之旅