select distinct a.* from 学生表 a,课程表 b,成绩表 c
where a.学号=c.学号 and b.课程号=c.课程号
and b.课程名='计算机组成与结构' and c.成绩=100

解决方案 »

  1.   

    select distinct a.* from 学生表 a,课程表 b,成绩表 c
    where a.学号=c.学号 and b.课程号=c.课程号
    and b.课程名='计算机组成与结构' and c.成绩=100
      

  2.   

    select a.* from 学生表 a left outer join 成绩表 c on a.学号=c.学号  left outer join 课程表 b on b.课程号=c.课程号 where b.课程名='计算机组成与结构' and c.成绩=100
      

  3.   

    select a.* from 学生表 a left outer join 成绩表 c on a.学号=c.学号  left outer join 课程表 b on b.课程号=c.课程号 where b.课程名='计算机组成与结构' and c.成绩=100
      

  4.   

    select a.* from 学生表 a left outer join 成绩表 c on a.学号=c.学号  left outer join 课程表 b on b.课程号=c.课程号 where b.课程名='计算机组成与结构' and c.成绩=100
      

  5.   

    为什么非得用嵌套SQL啊!,楼上用的连接查询不是挺好的吗?
    嵌套写法:SELECT *
    FROM 学生表
    WHERE (学号 IN
              (SELECT 学号
             FROM 成绩表
             WHERE (课程号 IN
                       (SELECT 课程号
                      FROM 课程表
                      WHERE 课程名 = '计算机组成与结构')) AND (成绩 = 100)))嵌套执行效率较慢,建议用楼上的语句!
      

  6.   

    select * from 学生表 
    where 学号 in (select 学号 from 成绩表 
    where 课程号 = (select 课程号 from 课程表 where 课程名 = '计算机组成与结构') 
    and 成绩 = 100)TO:hzm_8(☆) 嵌套比连接查询要慢吗?不是说嵌套可被数据库优化吗!!!
      

  7.   

    select distinct a.* from 学生表 a,课程表 b,成绩表 c
    where a.学号=c.学号 and b.课程号=c.课程号
    and b.课程名='计算机组成与结构' and c.成绩=100
      

  8.   

    select * from 学生表 
    where 学号 in (select 学号 from 成绩表 
    where 课程号 = (select 课程号 from 课程表 where 课程名 = '计算机组成与结构') 
    and 成绩 = 100)
      

  9.   

    select * from 学生表 
    where 学号 in (select 学号 from 成绩表 
    where 课程号 = (select 课程号 from 课程表 where 课程名 = '计算机组成与结构') 
    and 成绩 = 100)
      

  10.   

    这样的问题可以用连接、也可以用子查询(嵌套)实现
    连接:
    select students.*
    from students,courses,points
    where points.成绩=100 and 
          courses.课程名='计算机组成与结构' and
          points.课程号=courses.课程号 and
          points.学号=students.学号子查询:
    select *
    from students
    where students.学号 in(select points.学号
                            from points
                            where points.成绩=100 and
                                points.课程号=(select courses.课程号
                                                from courses
                                             where courses.课程名=
                                             '计算机组成与结构'))
      

  11.   

    连接:
    select a.*
    from a,b,c,
    where a.学号=c.学号 and
          b.课程号=c.课程号 and
          b.课程名='计算机组成与结构' and
          c.成绩=100子查询(嵌套):
    select a.*
    from a
    where a.学号 in (select c.学号
                     from c
                     where c.成绩=100 and
                           c.课程号=(select b.课程号
                                    from b
                                    where b.课程名='计算机组成与结构'))
    有些SQL语句既可以用连接也可以用子查询
    但是,如果查询结果的列来自多个表则只能用连接;
          如果中间查询结果是统计则只能用子查询。
    这是我个人体会,不知对不对。
      

  12.   

    这样的问题可以用连接、也可以用子查询(嵌套)实现
    连接:
    select students.*
    from students,courses,points
    where points.成绩=100 and 
          courses.课程名='计算机组成与结构' and
          points.课程号=courses.课程号 and
          points.学号=students.学号子查询:
    select *
    from students
    where students.学号 in(select points.学号
                            from points
                            where points.成绩=100 and
                                points.课程号=(select courses.课程号
                                                from courses
                                             where courses.课程名=
                                             '计算机组成与结构'))
      

  13.   

    select * from 学生表
    where 学生表.学号 in
    (select 成绩表.学号 from 成绩表, 课程表
     where 成绩表.课程号= 课程表.课程号 and
    成绩表.成绩 = 100 and
    课程表.课程名 = '计算机组成与结构');