Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

UPDATE

UPDATE

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:

Example

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”:

Example

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!