不积跬步,无以至千里

博客园 首页 新随笔 联系 订阅 管理
现在又两张表
a:
姓名 年龄 性别
张三 30 男
李四 32 男
b:
姓名 年龄 性别
张雪 35 女
李雪 29 女
现在想得到
C:
姓名 年龄 性别
张三 30 男
李四 32 男
张雪 35 女
李雪 29 女

用Oracle该怎么做到?

如果不需要去除重复数据就用
select * from A union all select * from B;
如果需要去除重复数据就用
select * from A union select * from B;
这个是官方解释:
UNION
All distinct rows selected by either query

UNION ALL
All rows selected by either query, including all duplicates
备注:
①如果A表的列名和B表的列名不一样,取前一个查询的列名,但两表的数据类型必须一致
②另外介绍下这两个
INTERSECT
All distinct rows selected by both queries
这个是求交集
MINUS
All distinct rows selected by the first query but not the second
这个是做差
使用方法相同
posted on 2016-03-25 11:19  Zeroassetsor  阅读(493)  评论(0)    收藏  举报