What are the different types of SQL joins?

Learn SQL with Udemy

For an instructor lead, in-depth look at learning SQL click below.


SQL joins are used to combine rows from two or more tables, based on a related column between them. Let’s break down four main types of SQL joins: INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN.

1. INNER JOIN:

The INNER JOIN keyword selects records that have matching values in both tables. Here is an example of INNER JOIN:

2. LEFT JOIN (or LEFT OUTER JOIN):

The LEFT JOIN keyword returns all records from the left table (table1), and the matched records from the right table (table2). If there is no match, the result is NULL on the right side. Here is an example of LEFT JOIN:

3. RIGHT JOIN (or RIGHT OUTER JOIN):

The RIGHT JOIN keyword returns all records from the right table (table2), and the matched records from the left table (table1). If there is no match, the result is NULL on the left side. Here is an example of RIGHT JOIN:

4. FULL JOIN (or FULL OUTER JOIN):

The FULL JOIN keyword returns all records when there is a match in either left (table1) or right (table2) table records. If there is no match, the result is NULL on both sides. Here is an example of FULL JOIN:

Understanding these joins will allow you to pull together data from different tables effectively, making your SQL code more efficient and your analyses more meaningful. Keep practicing and you find out that the power of SQL is enormous!

Leave a Comment