MySQL UNION 操作符用于连接两个以上的 SELECT 语句的结果组合到一个结果集合中

union 会删除重复数据

union all 不会删除重复数据

select * from 
(
select *,'a' as kind from tablea where name is not null 
union all 
select *, 'b' as kind from tableb where name = 'b-data'
) a

MySQL UNION 操作符

原文地址:https://www.cnblogs.com/myesn/p/15062811.html