Practice · History · Medium
Return each monument and the era of the pharaoh who built it. Return columns name and era, ordered by monument name.
Runs in your browser. No signup needed.
monuments(name, builder, …) joins pharaohs(name, era) where monuments.builder = pharaohs.name. Alias the tables (m, p).
SELECT m.name, p.era
FROM monuments m
JOIN pharaohs p ON m.builder = p.name
ORDER BY m.name;
The reference solution is checked automatically when you run your query on the practice page — results are compared row by row, and order matters for this one.
A JOIN stitches two tables together on a matching key — the single most important idea in relational databases. (SQLite docs)