码迷,mamicode.com
首页 > 数据库 > 详细

******常见数据库笔试题*****

时间:2014-10-25 18:32:41      阅读:245      评论:0      收藏:0      [点我收藏+]

标签:sp   数据   div   bs   数据库   sql   nbsp   计算机   rom   

学生表:Student 学生表 (学号,姓名,性别,年龄,组织部门)

           Course 课程表 (编号,课程名称)
               Sc 选课表 (学号,课程编号,成绩)
表结构如下:
(1).写一个SQL语句,查询选修了’计算机原理’的学生学号和姓名
(2).写一个SQL语句,查询’周星驰’同学选修了的课程名字
(3).写一个SQL语句,查询选修了5门课程的学生学号和姓名
       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
                )

******常见数据库笔试题*****

标签:sp   数据   div   bs   数据库   sql   nbsp   计算机   rom   

原文地址:http://www.cnblogs.com/wuyuankun/p/4050365.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!