简答题
MySQL数据程序设计
题号 #3613541
设计题
学生表:Student 学生表 (学号,姓名,性别,年龄,组织部门)
Course 课程表 (编号,课程名称)
Sc 选课表 (学号,课程编号,成绩)
表结构如下:
Student(sno,sname,sex,age,department)
Course(cno,cname)
Sc(sno,cno,grade)
(1).写一个SQL语句,查询选修了’计算机原理’的学生学号和姓名
(2).写一个SQL语句,查询’周星驰’同学选修了的课程名字
(3).写一个SQL语句,查询选修了5门课程的学生学号和姓名
参考答案
暂无
答案解析
(1)select sno,sname from student where sno in ( select sno from sc where cno = ( select cno from course where cname=’计算机原理’) ) ;
(2) select cname from course where cno in ( select cno from sc where sno = ( select sno from student where sname=’周星驰’) ) ;
(3) select sno,sname From student Where sno in ( select sno from sc group by sno having count(sno)=5);
(2) select cname from course where cno in ( select cno from sc where sno = ( select sno from student where sname=’周星驰’) ) ;
(3) select sno,sname From student Where sno in ( select sno from sc group by sno having count(sno)=5);