用SQL语句实现:学生表、课程表、选课表三张表中的问题:
学生表:student(学号:sno、姓名:sname、性别:sgender、年龄:sage)
课程表:couse (课程编号:cno、课程名称:cname)
选课表:sc(学号:sno、课程编号:cno、成绩:marks)
问题一:查询选了”计算机原理“的学生学号和姓名?
select s.sno,s.sname from student s,sc t where s.sno = t.sno
and t.cno = (select c.cno from couse c where c.cname=‘计算机原理‘)
问题二:查询”周星驰“同学选修的课程名字?
select c.name from student s,couse c,sc t where c.no = t.cno
and t.sno =s.sno and s.sname = ‘周星驰‘
问题三:选秀了5门课程的学生学号和姓名?
select s.sno,s.sname from student s where s.no in
(select t.sno from sc t group by t.sno having count(t.cno)=5)
原文:http://www.cnblogs.com/sunn3d/p/3895974.html