FULL JOIN is a type of JOIN that returns all rows from both tables. If the tables have a match, the rows are combined into a single result row. If there is no match, the missing values are filled with NULL. In other words, FULL JOIN combines the behavior of LEFT JOIN and RIGHT JOIN at the same time.
Let's walk through an example
We have two tables: users and subscriptions. Our goal is to get all users and all subscriptions, even if some users have no subscription, or if there is a subscription that is not linked to any user.
The query looks like this. Let's break it down in more detail:
After running the query, we get the following result:
Key takeaways
FULL JOIN returns all records from both tables. If there is a match, the data is combined. If there is no match, one side will contain NULL.