Blog · Guide

SQL JOIN Explained with a Simple Shop Example

INNER JOIN and LEFT JOIN explained with customers and orders — the same mental model as looking up a name in another spreadsheet.

orders order_id customer_id ← status JOIN customers → customer_id first_name city row
A JOIN stitches tables together using a shared key (here: customer_id).

Why JOINs exist

In a shop database you don’t paste the customer’s full name onto every order. You store customer_id on the order, and keep names in customers. When you want both, you JOIN.

INNER JOIN — only matches

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

Think Excel: a VLOOKUP that only keeps rows with a successful match.

The shop pattern you’ll reuse

  1. orders → customers on customer_id
  2. order_items → products on product_id
  3. Chain both for a full receipt line

Try it yourself

The fastest way to lock this in is a short drill on the same Northstar Market tables.

Practice INNER JOIN

Related guides