數據庫筆試題

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章