join,in,exists都能实现,下面是in的:select sno,sname from student where sno in (select sno from sc where cno in (selelect cno from course where cname='计算机原理')); select cname from course where cno in (select cno from sc where sno in (select scno from student where sname='周星驰')); select sno,sname from student where sno in (select sno from sc group by sno having count(cno)>5);
四楼的解法是正确的,另外不用子查询也可以实现: 第一题: select sno,sname from course,student,sc where cname='计算机原理' and students.sno=sc.sno and sc.cno=course.cno; 第二题: select cname from course,student,sc where sname='周星驰' and students.sno=sc.sno and sc.cno=course.cno; 第三题: select sno,sname from student,course where students.sno=sc.sno group by sno having count(cno)=5);
where sno in (select sno from sc where cno in (selelect cno from course
where cname='计算机原理'));
select cname from course
where cno in (select cno from sc where sno in (select scno from student
where sname='周星驰'));
select sno,sname from student
where sno in (select sno from sc group by sno having count(cno)>5);
第一题:
select sno,sname
from course,student,sc
where cname='计算机原理' and students.sno=sc.sno and sc.cno=course.cno;
第二题:
select cname
from course,student,sc
where sname='周星驰' and students.sno=sc.sno and sc.cno=course.cno;
第三题:
select sno,sname
from student,course
where students.sno=sc.sno
group by sno
having count(cno)=5);