JOIN
Description
The JOIN
statement is used to combine rows from two or more tables.
The following figure shows seven usages of LEFT JOIN
, RIGHT JOIN
, INNER JOIN
, and OUTER JOIN
.
SELECT [select_list] FROM TableA A LEFT JOIN TableB B ON A.Key=B.Key |
|
SELECT [select_list] FROM TableA A LEFT JOIN TableB B ON A.Key=B.Key WHERE B.Key IS NULL |
|
SELECT [select_list] FROM TableA A RIGHT JOIN TableB B ON A.Key=B.Key |
|
SELECT [select_list] FROM TableA A RIGHT JOIN TableB B ON A.Key=B.Key WHERE A.Key IS NULL |
|
SELECT [select_list] FROM TableA A INNER JOIN TableB B ON A.Key=B.Key |
|
|
|
SELECT [select_list] FROM TableA A FULL OUTER JOIN TableB B ON A.Key=B.Key |
|
SELECT [select_list] FROM TableA A FULL OUTER JOIN TableB B ON A.Key=B.Key WHERE A.Key IS NULL OR B.Key IS NULL |
|
For more information, see the reference below: