集合运算
union
、intersect
、except
对应于∪、∩、-运算
并运算union
union
自动去除重复,如果想保留所有重复,则用union all
代替union
(select course_id
from section
where semester = 'Fall' and year = 2009)
union
(select course_id
from section
where semester = 'Spring' and year = 2010)
交运算intersect
intersect
自动去除重复,如果想保留所有重复,则用intersect all
代替intersect
(select course_id
from section
where semester = 'Fall' and year = 2009)
intersect
(select course_id
from section
where semester = 'Spring' and year = 2010)
差运算
except
在操作前自动去除输入重复,如果想保留所有重复,则用except all
代替except
(select course_id
from section
where semester = 'Fall' and year = 2009)
except
(select course_id
from section
where semester = 'Spring' and year = 2010)