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 update the content of lastname
for every entry in the customers
table. The old and new contents of the database table are illustrated below on the left and right respectively:
Notice: It is necessary to use conditional clauses (WHERE) in UPDATE query. If you do not use any conditional clause then all records of that table’s attribute will be updated. In above example new value (Smith) of lastname in customers table set to all rows.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents