SQL join diagram

SQL join diagram - Techronology

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.

Inner - Techronology
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.

SQL join diagram - Left join - Techronology
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.

Right - Techronology
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.

SQL join diagram - Left excluding join - Techronology
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.

Right - Techronology
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.

SQL join diagram - Outer join - Techronology
SELECT <data> 
FROM table_A A 
FULL OUTER JOIN table_B B 
ON A.Key = B.Key
Outer excluding join

Exclude matching data only.

Outer excluding - Techronology
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


Techronology home Reference desk