SQL JOIN for Beginners Part 2: Types of Joins

Suin LeeSuin Lee
1 min read

JOIN in SQL is used to combine rows from two or more tables based on a related column.
The main types of JOIN are as follows:

Using Venn Diagrams can make understanding much easier.

You can explore examples with diagrams and SQL statements on SQL Joins Visualizer.

1. INNER JOIN

  • Retrieves only the data where keys match in both tables A and B.

  • Excludes rows that exist only in A or only in B.

2. LEFT JOIN(LEFT OUTER JOIN)

  • Retrieves all data from the left table (A).

  • If the key from A exists in B, the corresponding data from B is included.

  • Includes rows that exist only in A.

3. RIGHT JOIN(RIGHT OUTER JOIN)

  • Retrieves all data from the right table (B).

  • If the key from B exists in A, the corresponding data from A is included.

  • Includes rows that exist only in B.

4. FULL OUTER JOIN

  • Retrieves all data from both tables.

  • Includes both matching rows and non-matching rows from A and B.

Next, we will learn more about JOIN statements in detail through practical examples :)

1
Subscribe to my newsletter

Read articles from Suin Lee directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Suin Lee
Suin Lee