union 取并集 相当于or
sql:(select a from tb1 where b) union (select b from tb2 where c)
解释:查询满足b条件或者满足c条件的结果
备注:union 自动去重复,union all保留所有重复
intersect 取交集 相当于and
sql:(select a from tb1 where b) intersect (select b from tb2 where c)
解释:查询满足b条件同时满足c条件的语句
备注:intersect自动去重复
minus(ORACLE) 取两个查询语句的差
sql:select distince * from tb1 where b minus selectdistince * from tb2 where b
解释:满足tb1但不满足tb2的数据,相当于第一个查询结果减第二个查询结果(如查询本月较上月增长的某数据)
except(SqlServer,MySql)取两个查询语句的差
语法及逻辑同minus