我打算在Postgresql中基于多个SELECT编写一个INSERT INTO请求,但没有成功。我有一个包含我所选数据的表(srctab),另一个表用于插入数据(dsttab)。以下是我运行的内容:
INSERT INTO dsttab (dstfld1, dstfld2) WITH
t1 AS (
SELECT srcfld1
FROM srctab
WHERE srcfld3 ='foo'
),
t2 AS (
SELECT srcfld5
FROM srctab
WHERE srcfld6 ='bar'
) select srcfld1, srcfld5 from srctab;
请问您能够帮忙让这个工作起来吗?谢谢!