并集:union
eg:
求学过002或者003课程同学的学号:
select s# from sc where c#='002'
union
select s# from sc where c#='003'
等同于
select s# from sc where c#='002' or c#='003'
交集:intersect
eg:求学过002和003课程同学的学号:
select s# from sc where c#='002'
intersect
select s# from sc where c#='003'
等同于
select s# from sc where c#='002'and s# in(
select s# from sc where c#='003')
差集:except
eg:求没学过002号课程的学号
select distinct s# from sc
except
select s# from sc where c#='002'
等同于
select distinct s# from sc sc1
where not exists(
select * from sc
where c#='002' and s#=sc1.s#)
先写下了吧,以后写作业用到可以回来看看呢;