2016-01-28 143 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 
相关问题