//是不是子查询是=就不可以用exists呢?但是=也可以换成In啊,用in的地方不是就可以换成exists吗?但是这里结果不对
student(sno,sname,sdept);course(cno,cname,ccredit);sc(sno,cno,grade)
1、找出学分为4分以上的课程的选修情况,列出学号,课程名,成绩
select sno,cname,grade from sc,course
where sc.cno = course.cno and
sc.cno in(select cno from course where ccredit >4)
select sno,cname,grade from sc,course
where sc.cno = course.cno and
exists(select *from course where sc.cno = cno and ccredit >4)
//这里in换成exists是对的
2、查询和数据结构相同学分的课程
select cno,cname,ccredit from course
where ccredit=(select ccredit from course where cname = '数据结构')
and cname <> '数据结构'; //这里返回了与数据结构相同学分的另外的课
--有问题
select cno,cname,ccredit from course x
where exists(select * from course where cname = '数据结构' and x.cno = cno); //但是这里只返回了数据结果,没有其余的课