This reference provides a brief summary of SQL join types. Overall, it focuses on the main types of joins in a relational database. Keep in mind, the above image is large and may be difficult to view on some screens. Therefore, we will breakdown the types separately.
Quick glance of SQL join types
Below are brief snapshots of the seven main types of joins in relational databases.
Types of joins
Here are the types of joins in SQL.
Inner join
Only show results where dataset A and dataset B have matching values.
SELECT <data>
FROM table_A A
INNER JOIN table_B B
ON A.Key = B.Key
Left join
Show all results from dataset A, and only results from dataset B that match dataset A.
SELECT <data>
FROM table_A A
LEFT JOIN table_B B
ON A.Key = B.Key
Right join
Show all results from dataset B, and only results from dataset A that match dataset B.
SELECT <data>
FROM table_A A
RIGHT JOIN table_B B
ON A.Key = B.Key
Left excluding join
Show only results from dataset A, and exclude matching results.
SELECT <data>
FROM table_A A
LEFT JOIN table_B B
ON A.Key = B.Key
WHERE B.Key IS NULL
Right excluding join
Show only results from dataset B, and exclude matching results.
SELECT <data>
FROM table_B B
RIGHT JOIN table_A A
ON A.Key = B.Key
WHERE A.Key IS NULL
Outer join
Show all the data.
SELECT <data>
FROM table_A A
FULL OUTER JOIN table_B B
ON A.Key = B.Key
Outer excluding join
Exclude matching data only.
SELECT <data>
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
Questions or comments
If you have any questions or comments, then send us an emal at support@techronology.com.
Related
- ASCII – American Standard Code for Information Interchange
- Unit circle – Reference
- Units of measurement – Reference guide