Career OS

Learn · SQL · Core

SQL Joins

Databases split data across tables to avoid repeating it. A JOIN is how you stitch those tables back together to answer a real question — like “which customer placed this order?”

Before we start

📋 What you’ll learn
  • What relational data is: tables, rows, keys
  • What a JOIN does and the 4 types you must know
  • Primary keys vs foreign keys
  • How to combine two tables into one answer
✅ After this you’ll be able to
  • Write an INNER and a LEFT join and know the difference
  • Explain how two tables relate through keys
  • Read a query that joins customers and orders

Why you’re learning it: joins are the single most-asked SQL topic, and every backend query touches them. Siemens tests DBMS basics directly. ⏱️ ~30 min.

First — tables and keys

A table is a grid: rows (records) and columns (fields). Instead of storing a customer’s name on every order, we keep customers in one table and orders in another, and link them by an id.

What a JOIN does

Two tables — customers and their orders:

customer_idname
1Darshan
2Amit
order_idcustomer_id
1011
1021

Join them on customer_id and you get a combined row per match: “order 101 → Darshan”, “order 102 → Darshan”. That’s essentially a VLOOKUP, done properly.

SELECT c.name, o.order_id
FROM customers c
JOIN orders o ON o.customer_id = c.customer_id;

The 4 join types

TypeReturns
INNER JOINOnly rows that match in BOTH tables (the overlap)
LEFT JOINALL left rows + matches from the right (nulls where none)
RIGHT JOINALL right rows + matches from the left
FULL JOINAll rows from both sides, matched where possible

Interview gold: LEFT JOIN is how you find “customers with no orders” — join, then filter where the right side is null.

Where you’ll use it — real life

📊 Every report

“Orders with customer names”, “payments with merchant details” — all joins.

🔁 Reconciliation

Joining a bank feed to your ledger on a reference id is your Recon project in one query.

🧾 Any app screen

A screen showing data from multiple tables is almost always a join underneath.

🔎 Finding gaps

LEFT JOIN + “where null” finds missing/unmatched records — the core of auditing.

Now YOU do the reps

🗣️ The 2-minute explain test

Out loud: “What’s the difference between an INNER and a LEFT join, and how would I find customers with no orders?” Then log it in your Journal.


Next: SQL Indexes →

Saves your progress on this device.