I'm trying to write an SQLite Query using sqliteonline.com that can:
Find the names of faculty members who teach in every room in which some class is taught.
This is what I have:
SELECT DISTINCT F.fname
FROM Faculty F
WHERE NOT EXISTS (( SELECT *
FROM Class C )
EXCEPT
(SELECT C1.room
FROM Class C1
WHERE C1.fid = F.fid ))
AND This is the error I get:
I've double checked and the parenthesis are balanced. So I'm kind of confused on where to go from here.
You must remove the parentheses that enclose each of the subqueries and select the same columns in each of them (I guess only room
is needed):
SELECT F.fname
FROM Faculty F
WHERE NOT EXISTS ( SELECT room FROM Class C
EXCEPT
SELECT C1.room
FROM Class C1
WHERE C1.fid = F.fid
)
Also DISTINCT
is not really needed, because you are selecting unique (I believe) fname
s from Faculty
.