
sql两表合并oracle
现在又两张表a:姓名年龄性别张三30男李四32男b:姓名年龄性别张雪35女李雪29女现在想得到C:姓名年龄性别张三30男李四32男张雪35女李雪29女请问各位大侠用Ora...
现在又两张表
a:
姓名 年龄 性别
张三 30 男
李四 32 男
b:
姓名 年龄 性别
张雪 35 女
李雪 29 女
现在想得到
C:
姓名 年龄 性别
张三 30 男
李四 32 男
张雪 35 女
李雪 29 女
请问各位大侠用Oracle该怎么做到? 展开
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
这个是做差
使用方法相同
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
这个是做差
使用方法相同
展开全部
试试:
select 姓名,年龄,性别 into c from (select 姓名,年龄,性别 from a union select 姓名,年龄,性别 from b)
不行就写两句:
select 姓名,年龄,性别 into c from a;
select 姓名,年龄,性别 into c from b;
select 姓名,年龄,性别 into c from (select 姓名,年龄,性别 from a union select 姓名,年龄,性别 from b)
不行就写两句:
select 姓名,年龄,性别 into c from a;
select 姓名,年龄,性别 into c from b;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
union 就行啊
select a.姓名,a.年龄,a.性别 from a union select b.姓名,b.年龄,b.性别 from b
select a.姓名,a.年龄,a.性别 from a union select b.姓名,b.年龄,b.性别 from b
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select * from a
union all
select * from b
union all
select * from b
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询