I have a table, where I am listing users attending a class. Below this table I want to have a <select>
field, with the list of users that do NOT attend the class.
Query that lists users attending the class:
SELECT * FROM User
left join UserCourse on User.id = UserCourse.fkStudentId
where UserCourse.fkCourseId = 1 and u.fkRoleId = 3;
And here is my code, where I try to list the "exceptions":
SELECT * FROM User where id !=
(SELECT id FROM User
left join UserCourse on User.id = UserCourse.fkStudentId
where UserCourse.fkCourseId = 1 and u.fkRoleId = 3);
The problem is, that there are several rows that match the 2nd query, and that isn't allowed. Do you have any suggestions how to to list the students that don't attend?