Skip to content
Advertisement

Query to find courses that all members are enrolled in

I have a database which contains 5 tables.

And I want to find the names of courses that are enrolled by all “Automotive Engineering” students.

I tried the below statements but it shows nothing.

I execute the above query but it shows nothing. Can someone help me from here?

Advertisement

Answer

This is a kind of relational division problem. Here is one approach using correlated subqueries for filtering

The first subquery computes how many Automative Engineering students enroll for the given course; we then ensure that this gives the same count as the total number of sudents in the department.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement