1

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?

5
  • incorrect syntax I think... update e set e.name = x.name from entities e inner join tmp_x x ON e.Ent_ID = x.Ent_ID Commented Nov 9, 2015 at 17:26
  • Stop using quoted identifiers. They are much more trouble than they are worth it. Commented Nov 9, 2015 at 17:51
  • @a_horse_with_no_name, what is the option when using table columns like Ent_ID, and not ent_id Commented Nov 9, 2015 at 17:52
  • Quite simple: if you don't quote it, you can write it any way you want ENT_ID or Ent_ID or ent_id Commented Nov 9, 2015 at 17:53
  • @a_horse_with_no_name, ok, thanks for the info. Commented Nov 9, 2015 at 17:56

1 Answer 1

5

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";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.