题目 :针对S_T数据库,查询只选修了“信息系统”和“数学”这两门课程的学生的基本信息。
解答:
select *
from student
where sno in(
select sno
from sc
group by sno
having count(*)=2 and sno in(
select b.sno
from course a,sc b
where a.cname='数学'and b.cno=a.cno
intersect
select b.sno
from course a,sc b
where a.cname='信息系统'and b.cno=a.cno))
先分组查找只选了两门课的学生,再查找两门课分别是选修了“信息系统”和“数学”的基本信息