PostgreSQL query — column does not exist

情到浓时终转凉″ 提交于 2021-02-11 05:28:18

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!