合并两个集合 union

来源:互联网 发布:苹果电脑装mac系统 编辑:程序博客网 时间:2024/05/16 11:57

1.  union all不去重

//例第一个集合20条数据,第二个集合10条数据   最后结果30条

select  * from (

select id,name from tab1

union all

select id,name from tab2

)



2.union 排重

//例第一个集合20条数据,第二个集合10条数据   有两条重复   最后结果28条

select  * from (

select id,name from tab1

union

select id,name from tab2

)



原创粉丝点击