次のテーブルがあります。
students (studentid, firstname, lastname)
finals (studentid, subjectid, finaldate, mark)
subjects (subjectid, subjectname, semester)
データベースの最終試験を受けた学生 (ID を表示) を知る必要があります。私は次のことをしました:
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';
また、データベースの最終試験を受けたことがない学生 (ID を提示) を知る必要がある場合はどうすればよいでしょうか?
やってることは同じか…
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';
ありがとう。