Manuals / SQL / Chapter 4

A · Query · beginner · Week 1–2 · Chapter 4 of 12

JOINs — inner, left, and relationships

Relational power: combine tables on keys. INNER JOIN keeps matches. LEFT JOIN keeps all left rows.

Path progress
28%

Step 1 of 3

INNER JOIN

customers INNER JOIN orders ON customers.id = orders.customer_id — only customers with orders.

INNER JOINDrag stickies · tap for tips
Study mapDrag stickies · tap for tipsKeep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Assert the UIdrag · tap →Retry wiselydrag · tap →Seed datadrag · tap →Close the loopdrag · tap →Keep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Pathwise hackdrag · tap →INNER JOINdrag · tap →Try thisdrag · tap →Follow the dashed drag · tap →

Example

SELECT o.id, c.name, o.total
FROM orders o
INNER JOIN customers c ON c.id = o.customer_id;

Do this now

SQLBolt lessons 6–8. List order id, customer name, total for each order.

Was this step clear?
Chapter learning outcomes
  • INNER JOIN
  • LEFT JOIN
  • Join conditions
  • Table aliases

Clear these before you leave

Side quest

Join diagram

Sketch ER diagram for your sandbox tables on paper.