2009-07-13 80 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