查询选修了A课程但是没有选修B课程的学号
select distinct 学号
from sc s1
where
not exists
(select * from sc where 学号=s1.学号 and 课程号='C2')
and exists (select * from sc where 学号=s1.学号 and 课程号='C1')
查询选修了A课程但是没有选修B课程的学号
select distinct 学号
from sc s1
where
not exists
(select * from sc where 学号=s1.学号 and 课程号='C2')
and exists (select * from sc where 学号=s1.学号 and 课程号='C1')