1、有两张表结构和数据如下:
这两张表有共同的数据 zs 18
select * from t_person_one
select * from t_person_two
2、测试union效果
可以看到union是去除了重复的数据
select * from t_person_one
union
select * from t_person_two
3、测试union all效果
可以看到union all并没有去除重复的数据
select * from t_person_one
union all
select * from t_person_two
4、注意事项:
union和union all要求两张表的字段数需一致,如果其中一张表不足,则在*这个位置增加补齐字段数让二者一致