Inner and Outer Joins
- INNER JOIN. An INNER join keeps only rows that match on both sides: customers who actually placed orders.
- LEFT JOIN. A LEFT join keeps every left row and fills missing right side with NULL: customers including those who never ordered.
- Join conditions. The ON clause states how rows pair up: almost always a key equality, and wrong conditions multiply rows.
Multi-Table Relationships
- Chaining joins. Real questions chain joins: orders to customers to cities: each ON clause one relationship link.
- Junction tables. Many-to-many needs a junction table: students_courses pairs ids, and two joins cross it.
- Self joins. A self join pairs a table with itself: employees to their managers through one alias each.
Designing Correct Joins
- Fan-out. Joining one row to many multiplies it: sum after an unnoticed fan-out and the total is silently wrong.
- Verify cardinality. Check row counts as you build: each join’s result should match the cardinality you predicted.
- Semi-joins. When you only ask “has at least one”, use EXISTS: it filters without multiplying anything.
Before and after this level
- Before: Level 2: Expressions & Data: Data Types, Operators and Functions, NULL and Three-Valued Logic.
- Next: Level 4: Aggregation: GROUP BY, Aggregate Functions, HAVING and Analytical Summaries.
In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.
Frequently asked questions
What does SQL Level 3: Joining Data cover?
Inner and Outer Joins, Multi-Table Relationships, Designing Correct Joins: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Level 2: Expressions & Data, which covers Data Types, Operators and Functions, NULL and Three-Valued Logic.