Practice · Education · Medium
Return the cities that are BOTH a university city AND a governorate name in our data, alphabetically.
Runs in your browser. No signup needed.
SELECT city FROM universities INTERSECT SELECT name FROM governorates. INTERSECT keeps only rows present in both sets.
SELECT city FROM universities
INTERSECT
SELECT name FROM governorates
ORDER BY city;
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.
INTERSECT is set algebra in SQL — the overlap of two lists, no join required. (SQLite docs)