1、

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

           Course 课程表 (编号,课程名称)

               Sc 选课表 (学号,课程编号,成绩)

表结构如下:

(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
                )


更多笔试题请参照http://tntxia.iteye.com/blog/771497

j_0011.gif