0 to Hero SQL
A roadmap through SQL, from a first SELECT to isolation levels and query plans — written against PostgreSQL and MySQL side by side, because the two disagree exactly where it costs you.
What you'll learn
- Read and write everyday SQL without guessing what the engine will do with it
- Reason about NULL correctly, including the comparisons that quietly return nothing
- Choose the right join, and recognise the accidental cross join before it runs
- Replace a nested subquery with a CTE or a window function when that is the clearer tool
- Design a schema whose constraints make the wrong row impossible to insert
- Read EXPLAIN on both engines and say why an index was not used
- Pick an isolation level deliberately, and explain the anomaly it still allows
- Write the production patterns — upsert, keyset pagination, an online migration — for both engines
Course content
Foundations3 lessons · 48m
Joins and shaping3 lessons · 55m
Design2 lessons · 42m
Production2 lessons · 42m
Requirements
- PostgreSQL 14+ or MySQL 8.0+, locally or in Docker
- Willingness to run the queries rather than read them
A terminal and one of the two databases installed. No prior SQL. Lesson 8 onwards assumes you have written queries against a table with real rows in it.
Description
Most SQL material teaches one dialect and lets you discover the rest during an
incident. This roadmap uses PostgreSQL and MySQL together, and every lesson
that has a difference says so in a table rather than a footnote — because the
places they diverge are not trivia. The default isolation level is different. One
has FULL OUTER JOIN and the other does not. GROUP BY is strict in one and,
depending on how the server was configured, forgiving in the other. Those are the
things that turn a query that worked in staging into a bug report.
How the roadmap is ordered
Four stages, and they build:
- Foundations — the relational model,
SELECT, and the two things beginners get wrong first:NULLandGROUP BY. - Joins and shaping — joins, subqueries, CTEs, then window functions, which
are what you reach for once you stop trying to do it all with
GROUP BY. - Design — schema, constraints and types, then indexes and reading a query plan. This is where SQL stops being a language and starts being a system.
- Production — transactions and isolation, then the patterns you need on a live database: upserts, pagination that survives page 500, migrations that do not lock a table for ten minutes.
Nothing here is gated. Reading is free and always will be; you sign in only if you want the progress marks and the quiz results to belong to you.
The quizzes
There is one quiz per stage, not one per lesson, and that is deliberate: the interesting questions cross lessons. Each is 20 questions and tells you your score without telling you which ones you got wrong — you get a topic to go back to instead of an answer to memorise.
If you want a quick calibration first, the standalone SQL Basics quiz is a reasonable entry test. Score badly on it and start at lesson 1; score well and you can probably begin at lesson 4.
Who this is for
- Engineers who use an ORM and want to know what it is generating
- Anyone who has written SQL that worked on a small table and fell over on a large one
- Backend developers who have never been shown EXPLAIN