在两个表上使用union

问题描述 投票:0回答:1

当我尝试连接两个表时,它给出了错误。两个表的列数相同

这是错误

failed to find conversion function from unknown to text  

select * from table1
union
select * from table 2;
sql postgresql greenplum
1个回答
3
投票

当您使用UNION列时需要与相同位置相同的类型。

使用清晰的列名而不是*,因为我们无法预测table1table2之后的列数不同。

select col1,col2...
from table1
union
select col1,col2...
from table2;
© www.soinside.com 2019 - 2024. All rights reserved.