首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

多表拼接有关问题

2012-03-30 
多表拼接问题现有多个格式相同的表例如select * from a--------------id name1 1112 222select * from b--

多表拼接问题
现有多个格式相同的表 
例如 

select * from a 
--------------
id name 
1 111
2 222

select * from b
---------------
id name 
3 333
4 444

select * from c
---------------
id name 
5 555
6 666

现在需要查询的结果为

id name 
1 111
2 222
3 333
4 444
5 555
6 666

请问各位大大,语句应该怎么来写呢?

[解决办法]

SQL code
    select d.* from     (select * from a  union      select * from b  union      select * from c     ) d
[解决办法]
又是 union
如果要保留重复的 就是union all

热点排行