0
如何連接三個具有相同主鍵並且構成一個視圖的表?任何線索將不勝感激。連接具有相同主鍵的表
我有3個表sttm_customer
,sttm_customer_c
和sttm_customer_custom
, ,它們都與customer_no有共同點。
我需要做一個視圖STVW_CUSTOMER_TEMP
合併所有這些。
如何連接三個具有相同主鍵並且構成一個視圖的表?任何線索將不勝感激。連接具有相同主鍵的表
我有3個表sttm_customer
,sttm_customer_c
和sttm_customer_custom
, ,它們都與customer_no有共同點。
我需要做一個視圖STVW_CUSTOMER_TEMP
合併所有這些。
如果我理解你想要做什麼,你可以使用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
另外,還有一些共同的所有三個表的一些列。 – vhd
爲什麼你有3個幾乎相似的桌子?似乎糟糕的分貝設計。 – jarlh