Module F-5·23 min read

INNER JOIN, LEFT JOIN, FULL OUTER JOIN, self-joins, and multi-table queries — the most feared concept made simple.

JJS
Written by Jatin Jain Saraf · Senior Software Engineer

F-5 — Connecting Tables — Joins Demystified

Who this module is for: You completed F-4 and understand aggregation. Now you need to combine data from multiple tables — the foundational skill that makes relational databases genuinely powerful. Joins confuse almost every beginner because they require a new mental model. This module builds that model step by step.


Why Data Lives in Multiple Tables

Imagine a simple online store. You could store everything in one table:

text

This has problems:

  • Alice's email is stored twice — if she changes it, you must update multiple rows
  • The Keyboard's price is stored twice — if it changes, you must update multiple rows
  • Adding a new customer who has not ordered yet is impossible without a fake order
  • Removing all orders for a customer accidentally removes their account

The solution: split the data into separate tables, each representing one concept, and connect them with foreign keys.

text

Now Alice's email lives in one place. The Keyboard's price lives in one place. Joins let you reconstruct the combined view when you need it.


Setting Up the Example Schema

Create these tables to follow along:

sql

INNER JOIN — Only Matching Rows

An INNER JOIN returns rows that have a match in both tables. If a customer has no orders, they do not appear. If an order references a customer that doesn't exist, it doesn't appear.

sql

Notice:

  • David does not appear — he has no orders
  • Laptop Sleeve does not appear — nobody ordered it

The syntax:

sql

Using aliases to shorten table names:

sql

LEFT JOIN — Keep All Left Rows

A LEFT JOIN returns all rows from the left table, plus matching rows from the right. If there is no match in the right table, the right side columns are NULL.

sql

David appears with NULL values for the order columns because he has no orders — but he is not excluded. This is the key difference from INNER JOIN.

Sign in to keep reading

The rest of this module is free — sign in with Google to unlock it and track your progress.

Sign in & Register

Discussion

0

Join the discussion

Loading comments...

© 2026 Jatin Jain Saraf (JJS). All rights reserved.