【发布时间】:2022-01-02 07:36:28
【问题描述】:
我有这个查询并将行插入到 MYSQl 数据库中并且工作完美。
insert int test(id,user)
select null,user from table2
union
select null,user from table3
但是当在 PostgreSQL 中运行上述查询时不起作用。我得到这个错误column "id" is of type integer but expression is of type text,但是当我运行下面的两个查询时,如下所示。
当我在 PostgreSQL 中运行以下查询时,它可以正常工作:
insert into test(id,user)
select null,user from table2
或者在 PostgreSQL 的下面查询它可以正常工作:
insert int test(id,user)
select null,user from table3
或者在 PostgreSQL 的下面查询它可以正常工作:
select null,user from table2
union
select null,user from table3
【问题讨论】:
标签: postgresql union sql-insert