2016-03-11 63 views

回答

0

如果同時StudentsClosedSchoolsSchoolId場:

SELECT StudentId 
FROM Students stu 
WHERE NOT EXISTS (
    SELECT School 
    FROM ClosedSchools clo 
    WHERE clo.SchoolId = stu.SchoolId); 
0
SELECT StudentId 
FROM Students AS a 
WHERE NOT EXISTS (SELECT School 
        FROM ClosedSchools AS b 
        WHERE a.School = b.School) 
0
SELECT s.StudentId 
    FROM Students s 
WHERE NOT EXISTS (SELECT 1 
         FROM ClosedSchools 
        where ClosedSchools.School = s.School 
       ) 

SELECT s.StudentId 
    FROM Students s 
    LEFT JOIN ClosedSchools 
     on ClosedSchools.School = s.School 
WHERE ClosedSchools.School is null;