文章目录
- [union (并集)](#union (并集))
-
- [union distinct](#union distinct)
- [union all](#union all)
- intersect(交集)
-
- [intersect all](#intersect all)
- [intersect distinct](#intersect distinct)
- [except 差集](#except 差集)
-
- [except distinct](#except distinct)
- [except distinct](#except distinct)
- [except all](#except all)
union (并集)
union distinct
使用前提:a和c数据类型一致,b和d数据类型一致,查询的两个结果集列数也得相同
默认的union 即为union distinct
select a,b from table1
union
select c,d from table2;
union all
并集不去重
MySQL只支持union
intersect(交集)
intersect all
intersect distinct
except 差集
except distinct
except 差集