Sqlserver
 sql >> Datenbank >  >> RDS >> Sqlserver

Wählen Sie Zeilen aus, die sich nicht in einer anderen Tabelle befinden, SQL Server-Abfrage

SELECT SubjectID, DepartmentID, SubjectName, SubjectDescription, SubjectShortCode
FROM BS_Subject 
WHERE NOT EXISTS 
(SELECT SubjectToClassID FROM BS_SubjectToClass WHERE 
BS_Subject.SubjectID = BS_SubjectToClass.SubjectID
AND BS_SubjectToClass.ClassID =2)