I've got this homework for database 'SCHOOL'
- Table Student (StudentID, Name, Surname, etc..)\
- Table Application (ApplicationID, StudentID, ClassID)\
- Table Class (ClassID, ClassName, TeacherID)\
- Table Teacher (TeacherID, Name, Surname, etc..)
There are some other tables and columns in the database but I don't think they're important to this query.
I need to get name of the teachers for whose classes no student signed up. Let's say there is no one signed up for Math class, and I need to get the name of the teacher for that Math class.
SELECT Teacher.Name, Teacher.Surname, Class.ClassName
FROM Teacher
INNER JOIN Class ON Class.TeacherID = Teacher.TeacherID
INNER JOIN Application ON Application.ClassID = Class.ClassID
INNER JOIN Student ON Student.StudentID = Application.StudentID
WHERE Application.PredmetID IS NULL
Help would be appreciated.
NOT EXISTSor aLEFT JOIN.