s(sno,sname,age,sex,sdept),各属性表示学号、姓名、年龄、性别、所在系
sc(sno,cno,g),各属性表示学号、课程编号、成绩
c(cno,cname),各属性表示课程编号、课程名字
以上是三个表查询选修了数据库原理这门课且成绩高于1001号学生数据库原理成绩的学生姓名同时在问一下:
1.Select sno,sname from s where not exists (select * from sc where s.sno=sc.sno and sc.g<60)
2.Select sno,sname from s where s.sdept not in (select sdept from s where sno=’1001’)
是什么意思!!

解决方案 »

  1.   

    not exists 不存在的意思
    not in     不包含的意思
      

  2.   

    select s.* from s,sc,c where s.sno=sc.sno and c.cno=sc.cno and c.cname='数据库原理' and sc.g>(select g from sc,c where sc.sno='1001' and sc.cno=c.cno and c.cname='数据库原理')
      

  3.   

    Select s.sno,s.sname from s left join sc on s.sno = sc.sno left join c on sc.cno = c.cno 
     where c.cname like '数据库原理' and  sc.g> 
    (select g from sc left join c where c.cname like '数据库原理' and sno = '1001')1、选择所有每一门课程的成绩都级格的学生编号和姓名
    2、选择所有和编号为'1001'在不同系的学生的编号和姓名
      

  4.   

    改一下:
    Select s.sno,s.sname from s left join sc on s.sno = sc.sno left join c on sc.cno = c.cno 
     where c.cname like '数据库原理' and  sc.g> 
    (select g from sc left join c on sc.cno = c.cno where c.cname like '数据库原理' and sno = '1001')1、选择所有每一门课程的成绩都级格的学生编号和姓名
    2、选择所有和编号为'1001'在不同系的学生的编号和姓名