JOIN
语法说明
JOIN
用于把来自两个或多个表的行结合起来。
下图展示了 LEFT JOIN
、RIGHT JOIN
、INNER JOIN
、 和 OUTER JOIN
。
SELECT / FROM TableA A LEFT JOIN TableB B ON A.Key=B.Key |
|
SELECT / FROM TableA A LEFT JOIN TableB B ON A.Key=B.Key WHERE B.Key IS NULL |
|
SELECT / FROM TableA A RIGHT JOIN TableB B ON A.Key=B.Key |
|
SELECT / FROM TableA A RIGHT JOIN TableB B ON A.Key=B.Key WHERE A.Key IS NULL |
|
SELECT / FROM TableA A INNER JOIN TableB B ON A.Key=B.Key |
|
|
|
SELECT / FROM TableA A FULL OUTER JOIN TableB B ON A.Key=B.Key |
|
SELECT / FROM TableA A FULL OUTER JOIN TableB B ON A.Key=B.Key WHERE A.Key IS NULL OR B.Key IS NULL |
|
更多信息,参考: