MySQL UPDATE Statement
The UPDATE
statement is used to update data in a database table. When using the UPDATE
statement, you specify the table name, the field to be updated, and its new value.
The above statement updates record 204
to have a last name of "Flanders". This results in "Marge Rubble" becoming "Marge Flanders".
If we run a SELECT
statement before and after the UPDATE
statement, here's the result.
Before:
After:
Update Multiple Fields
You can update multiple fields by using a comma to separate each field assignment. Like this:
Result:
The examples on this page use the Sakila sample database.