Zeusofolus
Zeusofolus

Reputation: 25

Add numerical value to every numerical value of a column mysql

I have a database with a rate column with numerical data. I would like to update the data in this column by adding 20 to each.

I am trying,

UPDATE 'refinance' SET 'rate' = rate + 20 

I get a syntax error when I simulate this query :

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''refinance' SET 'rate' = rate + 20' at line 1

Thanks for the input on this. Eric

Upvotes: 1

Views: 62

Answers (2)

Zeusofolus
Zeusofolus

Reputation: 25

So it turns out this query works after all, I only get the error when I press the "Simulate Query" button in phpMyAdmin when I hit the "go" button it processes without error.

I am relatively new to sql so not sure why this would be the case or what the benefit of simulation is if it is not a representation of the actual syntax. Thanks to everyone for the input and time.

Eric

Upvotes: 0

Ponni
Ponni

Reputation: 433

Please refer the update table syntax, you need to specify the tablename not table keyword.

UPDATE refinance SET rate = rate + 20; 

https://dev.mysql.com/doc/refman/5.7/en/update.html

https://www.w3schools.com/sql/sql_update.asp

Upvotes: 1

Related Questions