我尝试使用子查询更新postgresql表
UPDATE
bc
SET
(r, w) = ($1, $2)
WHERE
bc.sr_id IN (
UPDATE
sr
SET
(r, w) = ($1, $2)
WHERE
si = $3 AND
rti = $4 AND
fc = $5
RETURNING sr.id
)
为什么会返回错误?
答案 0 :(得分:2)
你不能像这样链接DML语句。您将不得不使用可写的CTE。
WITH buz AS
(UPDATE foo
SET num=0 WHERE num>5 RETURNING num)
UPDATE bar SET num=0 WHERE num IN
(SELECT num FROM foo);
SELECT * FROM foo;
SELECT * FROM bar;