Skip
Arish's avatar

223. EXISTS Operator


EXISTS

Returns TRUE if subquery returns any rows.

sql
1SELECT * FROM courses c
2WHERE EXISTS (
3  SELECT 1 FROM students s WHERE s.course_id = c.id
4);

Only courses with enrolled students.