How to update field to add value to existing value?
For example I have
Table name: table
id credit 1 4 2 5 3 3
Is there a way to simply add value to the credit?
like
UPDATE table SET credit = '+7' WHERE id='1'
I want to add 7 to 4 so that the credit=11 where id='1'
How to do this?
INSERT INTO Syntax 1. Specify both the column names and the values to be inserted: INSERT INTO table_name (column1, column2, column3, ...)
First, specify the table name that you want to change data in the UPDATE clause. Second, assign a new value for the column that you want to update. In case you want to update data in multiple columns, each column = value pair is separated by a comma (,). Third, specify which rows you want to update in the WHERE clause.
UPDATE table SET credit = credit + 7 WHERE id = 1
This is just a simple UPDATE
. Try the following.
UPDATE tableName SET Credit = Credit + 7 WHERE ID = 1
note that ID = 1
and ID = '1'
is the same as the server automatically parses it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With