Outer joins are a way to combine data from two tables while including unmatched values from one or both tables. There are three types of outer joins:
LEFT JOIN: This type returns unmatched rows from the left table and matched rows from both tables.
RIGHT JOIN: This type returns unmatched rows from the right table and matched rows from both tables.
FULL OUTER JOIN: This type returns unmatched rows from both tables, as well as matched rows from both tables.
It's always better to visualize it:

When performing an inner join, only rows that have matching values in both tables are returned. In contrast, an outer join can return rows with unmatched values in one or both tables.
Imagine you have 2 tables related to TikTok videos:
TikTok Videos Table:
This table contains information about various TikTok videos. Each row represents a video, and there is a unique identifier called "video_id" for each video. The table includes fields such as "likes," "shares," and "views."
| video_id | video_title | user_id | likes | shares | views |
|---|---|---|---|---|---|
| 1 | Dance Challenge | 101 | 150 | 50 | 500 |
| 2 | Funny Pets Compilation | 102 | 300 | 75 | 1000 |
| 3 | Cooking Tutorial | 103 | 200 | 45 | 800 |
| 4 | Travel Vlog | 104 | 75 | 20 | 300 |
TikTok Comments Table:
This table lists comments on TikTok videos, with one row per comment. The "video_id" field in this table corresponds to the "video_id" field in the TikTok Videos Table.
| comment_id | video_id | user_id | comment_text |
|---|---|---|---|
| 1 | 1 | 201 | Awesome dance moves! |
| 2 | 1 | 202 | I love this song! |
| 3 | 2 | NULL | These pets are hilarious! |
| 4 | 3 | 204 | Great recipe! |
When you use an outer join between these two tables:
So if you basically want to return all Tiktok video and Tiktok comments (you can comment on a story for example), you would use a FULL OUTER JOIN and the syntax is the same as other join types:
SELECT *
FROM tiktok_videos v
FULL OUTER JOIN tiktok_comments c on v.user_id = c.user_id
In this query, I am returning everything, including those with no video_id!
Now let's see some use case for this concept!

| 5 | Makeup Tutorial | 105 | 400 | 100 | 1500 |
| 5 | 5 | NULL | Your makeup looks amazing! |