我有以下表格:
students (studentid, firstname, lastname)
finals (studentid, subjectid, finaldate, mark)
subjects (subjectid, subjectname, semester)
我需要知道参加数据库期末考试的学生(出示身份证)。我做了以下事情:
select studentid
from finals
where subjectid in (select subjectid
from subjects
where subjectname = 'database');
如果我使用JOIN
insted of会得到相同的结果IN
吗?
select studentid
from finals f, subjects s
where f.subjectid = s.subjectid
and s.subjectname = 'database';
如果我需要了解从未参加过数据库期末考试的学生(出示身份证)怎么办?
这样做是不是一样...
select studentid
from finals
where subjectid not in (select subjectid
from subjects
where subjectname = 'database');
...比这个?
select studentid
from finals f, subjects s
where f.subjectid = s.subjectid
and s.subjectname <> 'database';
谢谢。