合并结果集
union 去除重复并且合并
union all 不去重复的记录
技巧: 要求合并的多个结果集中 列的类型和 列的数量必须相同
create table test1(
tid number(2),
tname varchar2(20)
);
insert into test1 values(1,'a');
insert into test1 values(2,'b');
insert into test1 values(3,'c');
commit;
select * from test1;
create table test2(
did number(2),
dname varchar2(20)
);
insert into test2 values(3,'c');
insert into test2 values(4,'d');
insert into test2 values(5,'f');
commit;
把查询 结果 合并成一个集
union
select * from test1
union
select * from test2;
union all
select * from test1
union all
select * from test2;