Update column value PostgreSQL

SqlPostgresql

Sql Problem Overview


I am trying to update the value of a column where it matches a certain userid, but it keeps giving a syntax error.

UPDATE user 
   SET balance = 15000.000000000 
 WHERE id = 11203;

The table called user has many rows with two columns, balance and id. I am trying to edit the balance of the user id in the code.

Sql Solutions


Solution 1 - Sql

Try "user", or give a more generic name:

UPDATE "user" 
 SET balance = 15000.000000000 
 WHERE id = 11203;

or ALTER your table name to "user_list" for example. Any doubt, please check keywords

Solution 2 - Sql

You need to escape user since it is a reserved word. Try

UPDATE "user"
SET balance = 15000.000000000 
WHERE id = 11203;

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser1449384View Question on Stackoverflow
Solution 1 - SqlcybertextronView Answer on Stackoverflow
Solution 2 - Sqljuergen dView Answer on Stackoverflow