2016-01-28 142 views
0

如何連接三個具有相同主鍵並且構成一個視圖的表?任何線索將不勝感激。連接具有相同主鍵的表

我有3個表sttm_customer,sttm_customer_csttm_customer_custom, ,它們都與customer_no有共同點。

我需要做一個視圖STVW_CUSTOMER_TEMP合併所有這些。

+0

另外,還有一些共同的所有三個表的一些列。 – vhd

+0

爲什麼你有3個幾乎相似的桌子?似乎糟糕的分貝設計。 – jarlh

回答

0

如果我理解你想要做什麼,你可以使用UNION:

SELECT customer_no (and any other matching columns) 
FROM sttm_customer 
UNION 
SELECT customer_no (and any other matching columns) 
FROM sttm_customer_c 
UNION customer_no (and any other matching columns) 
FROM sttm_customer_custom 
相關問題