目录
union和 union all操作符在SQL中的区别和使用方法
1、可以使用union合并两个或两个以上的语句结果集
注意点:
union合并的表内部的select语句必须拥有相同数量的列,列也必须拥有相似的数据类型;每个select语句中的列的顺序必须相同
示例:
select 字段名 from 表名 where 查询条件
union
select 字段名 from 表名 where 查询条件
union和 union all的区别
union all 会把列出所有的值 且效率高于union
union不会列出重复的值