English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Usage and examples of SQL UPDATE keyword

SQL Keywords Reference

UPDATE

The UPDATE command is used to update existing rows in the table.

The following SQL statement uses the new contactand New city to update the first customer (CustomerID = 1)

 UPDATE Customers
 SET ContactName = 'Alfred Schmidt', City = 'Frankfurt';
 WHERE CustomerID = 1;

The following SQL statement will update the contact name to 'Juan' for all records with the country (region) 'Mexico':

UPDATE Customers
SET ContactName = 'Juan';
WHERE Country = 'Mexico';

Note:Be careful when updating records in a table! Pay attention to the WHERE clause in the UPDATE statement. The WHERE clause specifies the records to be updated. If the WHERE clause is omitted, all records in the table will be updated!

SQL Keywords Reference