连接具有相同主键的表

时间:2016-01-28 06:51:33

标签: sql join view

如何连接具有相同主键的三个表并创建一个视图?任何线索将不胜感激。

我有3个表sttm_customersttm_customer_csttm_customer_custom,  customer_no与所有人共同拥有。

我需要制作一个视图STVW_CUSTOMER_TEMP合并所有视图。

1 个答案:

答案 0 :(得分: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