I have to update a table where a field is numeric. I want to update that field adding 4 to that field. For example, if I have the number 100, when the table is updated, the field shuold be 104. If the field has the value 800, after updating the value should be 804. Hoy can I do that with an SQL UPDATE Statement?
I hope my explanation had been clear.
UPDATE Adding values
Moderator: General Moderators
Code: Select all
UPDATE table SET col_1 = col_1+4 WHERE ....Code: Select all
$query = "UPDATE table SET field = field + 4 WHERE id = $id";
mysql_query($query);