关于SQL S而ver not exists语句

来源:互联网 发布:打印设置软件 编辑:程序博客网 时间:2024/05/23 02:06

题目:输入语句,利用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

结果:



我一直搞不明白那里出错了,然后直接简单暴力一点,用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

结果就出来了:


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