mysql的union all和union的用法区别
union all和union
MySQL UNION 操作符用于连接两个以上的 SELECT 语句的结果组合到一个结果集合中,多个 SELECT 语句会删除重复的数据。
union all
select polylineId from oc_current_day_revenue
union all
select id from oc_polylinedata
查出来的数据存在重复数据
union
select polylineId from oc_current_day_revenue
union
select id from oc_polylinedata
可以看到查出来的数据并无重复数据,因为我们项目里面也存在很多用到union的地方