Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 具有相同主键的联接表_Sql_Join_View - Fatal编程技术网

Sql 具有相同主键的联接表

Sql 具有相同主键的联接表,sql,join,view,Sql,Join,View,如何连接具有相同主键的三个表并生成一个视图?任何线索将不胜感激 我有三个表sttm\u customer,sttm\u customer\u c和sttm\u customer\u custom, 所有人都没有共同点 我需要创建一个视图,将所有视图合并起来。如果我了解您的意图,您可以使用UNION: SELECT customer_no (and any other matching columns) FROM sttm_customer UNION SELECT customer_no (a

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

我有三个表
sttm\u customer
sttm\u customer\u c
sttm\u customer\u custom
, 所有人都没有共同点


我需要创建一个视图,将所有视图合并起来。

如果我了解您的意图,您可以使用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

另外,这三个表还有更多的共同点。为什么有3个几乎相似的表?看起来db设计很差。