问题
I am trying to update a table using a temporary table.
Schema | Name | Type | Owner
------------+----------------------+----------+----------
pg_temp_11 | tmp_x | table | postgres
public | entities | table | postgres
However I am getting this error:
UPDATE entities SET "Name" = "tmp_x.Name" FROM tmp_x WHERE "entities.Ent_ID" = "tmp_x.Ent_ID";
ERROR: column "tmp_x.Name" does not exist -- the column Name exists
LINE 1: UPDATE entities SET "Name" = "tmp_x.Name" FROM tmp_x WHERE "...
What is the problem? The quotes around table columns?
回答1:
You are surrounding multiple individual objects with double quotes. If you are using object delimiters (double quotes), they need to be on each item, not on the entire combination:
UPDATE entities SET "Name" = "tmp_x"."Name" FROM tmp_x WHERE "entities"."Ent_ID" = "tmp_x"."Ent_ID";
来源:https://stackoverflow.com/questions/33614625/postgresql-query-column-does-not-exist