WITH upt as (
UPDATE backend."orders" SET "statusId" = 5
WHERE "userId" IN (177962,88265) and "statusId" IN (0,1,2,3,4) RETURNING *
)
INSERT INTO __test_result(orderid) VALUES ((SELECT orderid FROM upt))
Need to update and log data,getting this error
ERROR: column "orderid" does not exist Hint: There is a column named
"orderid" in table "__test_result", but it cannot be referenced from this part of the query.
How can I insert in table for all "upt" rows?It must look
"upt.orderid","jsonb for that orderid"
for every order jsonb must be created from "upt" column with same orderid