关于SQL S而ver not exists语句

题目:输入语句,利用NOT EXISTS谓词,查询没有选修“软件工程”的学生的学号和姓名

关于SQL S而ver not exists语句

关于SQL S而ver not exists语句

这个问题我想了好久,刚开始我是这样写的:

select student.sno,sname from student inner join sc 
on student.sno=sc.sno 
where not exists(select * from course where course.cno=sc.cno and cname='软件工程')
go

结果:

关于SQL S而ver not exists语句


我一直搞不明白那里出错了,然后直接简单暴力一点,用select嵌套语句:

select student.sno,sname from student
where not exists(select * from course 
where exists(select * from sc where student.sno=sc.sno and sc.cno=course.cno and cname='软件工程'))
go

结果就出来了:

关于SQL S而ver not exists语句

如果有知道前面的语句那里错的请指教!