UPDATE customers SET email='[email protected]' WHERE id=1
This query updates the content of email
in the customers
table to the string [email protected]
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:
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.