SQL Joins Explained With Examples

Reviewed & published by Brayan K

Master INNER, LEFT, RIGHT and FULL joins with practical SQL examples, visual tables, and real-world scenarios.

Master INNER, LEFT, RIGHT, and FULL joins with practical SQL examples and visual explanations.

Introduction

If you're learning SQL, one of the most important things you'll ever understand is JOINS. They're the backbone of combining data across multiple tables — which is how real databases actually work.

This guide breaks down SQL joins in a simple, visual, example-driven way so you can finally understand:

Let's make SQL joins easy.

1. What Are SQL Joins?

A JOIN allows you to combine rows from two or more tables based on a related column.

Without joins, each table is isolated.

With joins, tables become powerful relational data sources.

2. Example Tables Used in This Guide

Table: users

user_idname
1Alice
2Bob
3Charlie

Table: orders

order_iduser_idproduct
1011Laptop
1021Mouse
1032Keyboard

3. INNER JOIN (Most Common)

Returns matching rows from both tables.

Result:

nameproduct
AliceLaptop
AliceMouse
BobKeyboard

🧠 Charlie has no orders → not included.

You only want records that exist in both tables.

4. LEFT JOIN (LEFT OUTER JOIN)

Returns all rows from LEFT table + matching rows from RIGHT. Missing matches become NULL.

nameproduct
AliceLaptop
AliceMouse
BobKeyboard
CharlieNULL

🧠 LEFT = users, so all users appear, even those with no orders.

You want the "full list" of the primary table.

5. RIGHT JOIN (RIGHT OUTER JOIN)

Opposite of LEFT JOIN. Returns ALL rows from the RIGHT table + matches from LEFT.

Same data as INNER JOIN in this example, because all orders have matching users:

nameproduct
AliceLaptop
AliceMouse
BobKeyboard

Right table is the "main" table.

6. FULL OUTER JOIN

Returns ALL rows from both tables. Where no match exists → NULLs appear.

nameproduct
AliceLaptop
AliceMouse
BobKeyboard
CharlieNULL
NULLNULL

(The last NULL row only appears if orders exist with no matching user.)

You want everything from both sides.

👉 Great for auditing or data cleanup.

7. CROSS JOIN

Produces the Cartesian product of both tables. Every row in table A combines with every row in table B.

If 3 users × 3 orders → 9 rows.

Avoid for large tables — can explode rows.

8. SELF JOIN

A table joined with itself.

Useful for hierarchies like:

10. When to Use Which JOIN (Quick Guide)

JOINWhen to Use
INNER JOINKeep only matches
LEFT JOINKeep everything on left
RIGHT JOINKeep everything on right
FULL JOINKeep everything from both
CROSS JOINAll combinations
SELF JOINHierarchies or relationships

Conclusion

SQL joins are the foundation of working with relational databases. Once you understand how each join behaves — and when to use them — you unlock the ability to:

Related articles

Related lessons