在学校教学数据库中有三个基本表:
S(Sno,Sn,Age,Sex),其含义为:学生(学号,姓名,年龄,性别【M:男,F:女】

SC(Sno,Cno,Score),其含义为:选课(学号,课程号,成绩)
C(Cno,CnTeacher),其含义为:课程(课程号,课程名,任课老师)
其中加下划线的属性为主码,下面列出了一部分示例数据,注意:一个老师可以教多门课
程。
S 表
Sno Sn Age
--------------------
S1 Zhang 19
S2 Wang 20
……
SC 表
Sno Cno Score
----------------------
S1 C1 90
S1 C2 81
S2 C2 78
……
C 表
Cno Cn Teacher
-------------------------------
C1 Database Sun
C2 MIS Sun
C3 OS Liu
……
6、 查询所有的学生都学的课程号与课程名称(一些公共课,如英语、政治等)。
这个查询语句怎么写,求高手指教。

解决方案 »

  1.   

    再次接分insert into sc
    select 'S1','C1',90 union all 
    select 'S1','C2',81 union all 
    select 'S2','C2',78insert into c  
    select 'C1','Database','Sun' 
    union all select 'C2','MIS','Sun' 
    union all select 'C3','OS','Liu'select cno,cn from c where cno not in
    ( select cno from s,c  
      where not exists(select * from sc where cno=c.cno and sno=s.sno)
    )/*
    cno    cn         
    ------ ---------- 
    C2     MIS(所影响的行数为 1 行)*/