The UPDATE command is utilized to modify existing rows in a table.
The following SQL statement updates the first customer (CustomerID = 1) with a new contact person and a new city:
UPDATE Customers SET ContactName = ‘Alfred Schmidt’, City= ‘Frankfurt’ WHERE CustomerID = 1; |
The following SQL statement updates the contact name to “Juan” for all records where the country is “Mexico”:
UPDATE Customers SET ContactName=‘Juan’ WHERE Country=‘Mexico’; |
Note: Exercise caution when updating records in a table! Note the WHERE clause in the UPDATE statement, specifying which record(s) should be updated. Omitting the WHERE clause will result in updating all records in the table! |