Basic Update
suggest changeUpdating one row
UPDATE customers SET email='luke_smith@email.com' WHERE id=1
This query updates the content of email in the customers table to the string luke_smith@email.com where the value of id is equal to 1. The old and new contents of the database table are illustrated below on the left and right respectively:
Updating all rows
UPDATE customers SET lastname='smith'
This query updates lastname for every row in the customers table. The old and new contents of the table are illustrated below, on the left and right respectively:
Notice: Use a WHERE clause unless you intend to change every row. Without one, every row’s lastname is set to smith.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents