I'm trying to learn SQL and I'm having a little trouble here.
ID | P_Id | room |
======================
1 | 8 | A |
2 | 8 | A |
3 | 8 | B |
4 | 9 | B |
5 | 9 | B |
6 | 10 | C |
7 | 10 | C |
8 | 10 | D |
I'm trying to figure out which P_Id has only worked in room B. So the outcome would be P_Id = 9. Not 8 as well, because he worked in room A as well.
This is my query, but it doesn't work:
SELECT Room.P_Id
FROM Room
WHERE NOT EXISTS (SELECT *
FROM Room
WHERE Room.room <> 'B');
Could you guys help me out here?