The UPDATE statement lets you edit an existing row in a table.
UPDATE table_name SET column_name = "new value" WHERE row_name = "existing value"
Your employer has asked you to remove $5000 from the balance of the person whose ID=1003.
The SQL statement would be:
UPDATE customer SET Balance = Balance - 5000 WHERE id = 1003;
Let’s break down our statement:
UPDATEis followed by the name of the table
SETis followed by the column name
- On our example, we have to remove $5000 from existing value. That’s why, we have to
SETthe Balance to be equal to Balance subtracted by $5000.
- On the last line,
WHEREclause is used to specify the name of the row from which we want to reduce the value.