Introduction to SQL Joins for Absolute Beginners (with Simple Examples)
If you’ve just started learning databases and SQL, there’s one topic that often feels scary in the beginning: SQL Joins.
But trust me — once you understand the concept, they become one of the most powerful tools in your toolbox.
Think of JOINs like matching two lists based on something they have in common. That’s it.
Nothing magical. Nothing complicated. Just matching things.
Let’s walk through everything step-by-step, slowly and clearly, so even someone completely new (yes — total dummy level) will understand JOINs by the end of this tutorial.
⭐ Why Do We Need JOINs?
Imagine you run a small shop.
You may have:
Table 1: customers
| id | name |
|---|---|
| 1 | Alice |
| 2 | Bob |
| 3 | Charlie |
Table 2: orders
| id | customer_id | product |
|---|---|---|
| 1 | 1 | Laptop |
| 2 | 2 | Mouse |
| 3 | 1 | Keyboard |
| 4 | 4 | Monitor |
If you want to answer the question:
“Which customer bought which product?”
You can’t do it using just one table.
You need both.
That's where JOINs save the day.
⭐ The Different Types of SQL Joins
We’ll walk through each of these:
-
INNER JOIN
-
LEFT JOIN
-
RIGHT JOIN
-
FULL JOIN
I’ll keep everything super simple.
⭐ 1. INNER JOIN (The Most Common One)
What it means:
Give me only the data that exists in both tables.
Like:
“Show me customers that actually placed an order.”
Query:
Result:
| name | product |
|---|---|
| Alice | Laptop |
| Bob | Mouse |
| Alice | Keyboard |
Notice Charlie is NOT here — because he didn’t order anything.
⭐ 2. LEFT JOIN (Show Everything From the Left Table)
What it means:
Give me all customers,
and add their orders if they have any.
If none, put NULL.
Query:
Result:
| name | product |
|---|---|
| Alice | Laptop |
| Bob | Mouse |
| Alice | Keyboard |
| Charlie | NULL |
Charlie shows up this time — because LEFT JOIN keeps all customers.
⭐ 3. RIGHT JOIN (Opposite of LEFT JOIN)
What it means:
Show all orders,
and include the customer info if there is any.
Query:
Result:
| name | product |
|---|---|
| Alice | Laptop |
| Bob | Mouse |
| Alice | Keyboard |
| NULL | Monitor |
The order with customer_id = 4 has no matching customer — so name is NULL.
⭐ 4. FULL JOIN (Keep Everything From Both Tables)
Not all databases support FULL JOIN (MySQL doesn’t, PostgreSQL does).
What it means:
Show EVERYTHING — all customers + all orders.
Query (PostgreSQL):
Result:
| name | product |
|---|---|
| Alice | Laptop |
| Bob | Mouse |
| Alice | Keyboard |
| Charlie | NULL |
| NULL | Monitor |
This gives the biggest picture.
⭐ Visual Summary (Easy to Remember)
Think of JOINs like circles:
-
INNER JOIN → Only the overlapping part
-
LEFT JOIN → All from left + matching from right
-
RIGHT JOIN → All from right + matching from left
-
FULL JOIN → Every possible row from both
Once you see it like that, it sticks forever.
⭐ Common Beginner Mistakes (And How to Avoid Them)
❌ Mistake 1: Using the wrong column in the JOIN
Make sure you're joining using matching fields (foreign keys), not names or random columns.
❌ Mistake 2: Forgetting the table name
If both tables have a column called id, you MUST specify:
❌ Mistake 3: Thinking LEFT JOIN = INNER JOIN
LEFT JOIN keeps unmatched rows — INNER JOIN doesn’t.