Practice · Education · Medium

Cities that are both (INTERSECT)

Return the cities that are BOTH a university city AND a governorate name in our data, alphabetically.

Runs in your browser. No signup needed.

What you are given

SELECT city FROM universities INTERSECT SELECT name FROM governorates. INTERSECT keeps only rows present in both sets.

Starting point

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.

Did you know

INTERSECT is set algebra in SQL — the overlap of two lists, no join required. (SQLite docs)

More Education challenges

Open it in the playground →