赞
踩
可以通过下图直观看出 LEFT JOIN、RIGHT JOIN、INNER JOIN、OUTER JOIN等相关的7 种用法。
以下就是这七种用法的语句:
SELECT <select_list>
FROM Table_A A
INNER JOIN Table_B B
ON A.Key = B.Key
SELECT <select_list>
FROM Table_A A
LEFT JOIN Table_B B
ON A.Key = B.Key
SELECT <select_list>
FROM Table_A A
RIGHT JOIN Table_B B
ON A.Key = B.Key
SELECT <select_list>
FROM Table_A A
FULL OUTER JOIN Table_B B
ON A.Key = B.Key
SELECT <select_list>
FROM Table_A A
LEFT JOIN Table_B B
ON A.Key = B.Key
WHERE B.Key IS NULL
SELECT <select_list>
FROM Table_A A
RIGHT JOIN Table_B B
ON A.Key = B.Key
WHERE A.Key IS NULL
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
以上的图片以及语句均来自菜鸟教程,略加进行了整理。我们可以看出这七条语句经过图片展示后非常直观的给出了要查询的内容。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。