(2)这么写坑定不对,这么写得出的答案是“上过那个老师的课程的学生”而不是“上过那个老师所有课程的学生”,而且那个答案效率太低,还不如这个:
select sno,sname from student
where sno in(select sno from sc
where cno in (select cno from course
where tno in (select tno from teacher where tname='谌燕')));
select s.sno,s.sname from student s join sc c on s.sno=c.sno where c.sno not in (select distinct sno from sc where score>60);
第一个:
select sno,sname from student where sno not in (select sno from sc where score>=60)
第二个那个sc表中sno是sc表的主键还是student表的主键
select st.*,s.score from student st
inner join sc s on st.sno=s.sno
inner join course c on s.cno=c.cno
where s.score <60
掉了 inner 或者 left 或者 right