2009-07-13 78 views
3

我有表所示:合并与意义同一列的两个表为一个

Table Articles 
--------------- 
AID(PK) Name PublisherID Words 


Table Books 
--------------- 
BID(PK) Title PublisherID Date 

我想将它们合并喜欢:

Table Total 
--------------- 
Title PublisherID 

在这个新表,名称在Table.Articles将属于标题列, 因为..文章。 名称和Books。 标题意味着同样的事情:)

任何答案将是非常赞赏:)

感谢

回答

6
select title, publisherid from books 
union all 
select name, publisherid from articles 
+0

在oracle中,“CREATE TABLE as(David Aldridge查询)”创建具有apropiate结构的表并复制所有数据。 – Jonathan 2009-07-13 13:49:38

+0

非常感谢! 它完美的作品:) 我不知道'全部'命令。 – wooohoh 2009-07-13 13:51:56

1

据我所知,您正在寻找这样的结果:

select name, publisherId 
from TableArticles 
union 
select title, publisherId 
from TableBooks