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 / 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 | |
For more information, see the reference below: