第13讲++连接查询和子查询

 

 查询不及格学生的学号、姓名、课程号、成绩信息。

 

select   学号,姓名,课程号, 成绩
from     xsqk, xs_kc
where   xsqk.学号=xs_kc.学号    and   成绩<60

 

查询不及格学生的学号、课程名、授课教师、开课学期的信息。

 

select  学号,xs_kc.课程号, 授课教师,开课学期,成绩
from     kc, xs_kc
where   xs_kc.课程号=kc.课程号  and  成绩<60

 

查询最高分在80分以上的学号、姓名、联系电话(xsqk , xs_kc)

select   学号,姓名,联系电话     from    xsqk   a
where    (select    max(成绩)    from    xs_kc   b
               where    b.学号 = a.学号 )  >=80

查询每门课程的最低分。

 

select    *   from   xs_kc   a
where  成绩 <= all
(select  成绩  from  xs_kc  b  where  b.课程号=a.课程号)

 

查询有不及格学生的课程的授课教师

select    课程号,授课教师
from     kc
where  课程号  in
( select  课程号  from   xs_kc   where   成绩 < 60 )

 

posted @ 2017-05-19 17:18  该☆隐  阅读(472)  评论(0编辑  收藏  举报