Skip to content
Justice Tech School

EXISTS

EXISTS is true if the subquery returns any row. It is a clear way to ask whether a relation exists.

Example
SELECT name FROM students s
WHERE EXISTS (SELECT 1 FROM enrolments e WHERE e.student_id = s.id);

Result

name
Ada
Kofi
Amina
Tunde
Zainab

Exercise

Test any row.

WHERE  (SELECT 1)

Quiz Test

EXISTS returns?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.