0

I need to update field named 'from' in postgres. But i can not to do it.

Select working such:

SELECT table_name.from FROM table_name WHERE id=1 

But I can not do it with UPDATE:

production=# UPDATE table_name SET from='text' WHERE id=3482; ERROR: syntax error at or near "from" production=# update table_name set table_name.from='text' where id=3482; ERROR: column "table_name" of relation "table_name" does not exist LINE 1: update table_name set table_name.from=' 

Can you suggest a way to update a field 'from' in the table?

5
  • Have you tried using quotes around the from (like SELECT table_name."from" FROM table_name WHERE id=1) Commented Jul 19, 2021 at 11:31
  • See stackoverflow.com/questions/7651417/… for more details Commented Jul 19, 2021 at 11:31
  • Its not working ERROR: column "table_name" of relation "table_name" does not exist or ERROR: syntax error at or near "'from'" LINE 1: update table_name set table_name.'from'= Commented Jul 19, 2021 at 11:34
  • 2
    Mandatory read: Identifiers and Keywords in the Postgres manual Commented Jul 19, 2021 at 11:34
  • O! Its working! production=# update "table_name" set "from"='text' where id=3482; UPDATE 1 Thanks! Commented Jul 19, 2021 at 11:40

2 Answers 2

0

Use double quotes as such:

UPDATE table_name SET "from"='text' WHERE id=3482; 

Look at 4.1.1. Identifiers and Key Words for more info.

Sign up to request clarification or add additional context in comments.

Comments

-2

Change "from" to Your "Field Name"
UPDATE table_name SET "from" = value1 where id=1

2 Comments

Please share more details. I would assume that from is the name of the column
The column is named from - that's the problem

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.