Return data from subselect used in INSERT in a Common Table Expression
问题 I am trying to move bytea data from one table to another, updating references in one query. Therefore I would like to return data from the query used for the insert that is not used for the insert. INSERT INTO file_data (data) select image from task_log where image is not null RETURNING id as file_data_id, task_log.id as task_log_id But I get an error for that query: [42P01] ERROR: missing FROM-clause entry for table "task_log" I want to do something like: WITH inserted AS ( INSERT INTO file