SQL UPDATE Statement
SQL UPDATE Statement
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
UPDATE Syntax
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
https://www.w3schools.com/sql/sql_update.asp 1/13
1/22/25, 5:55 PM SQL UPDATE Statement
Note: Be careful when updating records in a table! Notice the WHERE clause in the UPDATE statement. The WHERE
Tutorials Exercises Certificates Services Sign Up Log in
clause specifies which record(s) that should be updated. If you omit the WHERE clause, all records in the table will be
updated!
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
Demo Database
Below is a selection from the Customers table used in the examples:
4 Around the Horn Thomas Hardy 120 Hanover Sq. London WA1 1DP UK
UPDATE Table
https://www.w3schools.com/sql/sql_update.asp 2/13
1/22/25, 5:55 PM SQL UPDATE Statement
The following SQL statement updates the first customer (CustomerID = 1) with a new contact person and a new city.
Tutorials Exercises Certificates Services Sign Up Log in
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
Example Get your own SQL Server
UPDATE Customers
SET ContactName = 'Alfred Schmidt', City= 'Frankfurt'
WHERE CustomerID = 1;
The selection from the "Customers" table will now look like this:
4 Around the Horn Thomas Hardy 120 Hanover Sq. London WA1 1DP UK
ADVERTISEMENT
https://www.w3schools.com/sql/sql_update.asp 3/13
1/22/25, 5:55 PM SQL UPDATE Statement
The following SQL statement will update the ContactName to "Juan" for all records where country is "Mexico":
Example
UPDATE Customers
SET ContactName='Juan'
WHERE Country='Mexico';
The selection from the "Customers" table will now look like this:
4 Around the Horn Thomas Hardy 120 Hanover Sq. London WA1 1DP UK
https://www.w3schools.com/sql/sql_update.asp 4/13
1/22/25, 5:55 PM SQL UPDATE Statement
5 Tutorials Berglunds
Exercisessnabbköp
Christina
Certificates
Berglund
Services Berguvsvägen 8 Luleå S-958 22
Sign UpSweden
Log in
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
Update Warning!
Be careful when updating records. If you omit the WHERE clause, ALL records will be updated!
Example
UPDATE Customers
SET ContactName='Juan';
The selection from the "Customers" table will now look like this:
https://www.w3schools.com/sql/sql_update.asp 5/13
1/22/25, 5:55 PM SQL UPDATE Statement
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
4 Around the Horn Juan 120 Hanover Sq. London WA1 1DP UK
?
Exercise
What is the purpose of the SQL UPDATE statement?
Submit Answer »
https://www.w3schools.com/sql/sql_update.asp 6/13
1/22/25, 5:55 PM SQL UPDATE Statement
❮ Previous
Tutorials Exercises Certificates Services Log❯in
Sign Up Next
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
ADVERTISEMENT
https://www.w3schools.com/sql/sql_update.asp 7/13
1/22/25, 5:55 PM SQL UPDATE Statement
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
https://www.w3schools.com/sql/sql_update.asp 8/13
1/22/25, 5:55 PM SQL UPDATE Statement
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
COLOR PICKER
ADVERTISEMENT
https://www.w3schools.com/sql/sql_update.asp 9/13
1/22/25, 5:55 PM SQL UPDATE Statement
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
ADVERTISEMENT
https://www.w3schools.com/sql/sql_update.asp 10/13
1/22/25, 5:55 PM SQL UPDATE Statement
Tutorials
ADVERTISEMENT
Exercises Certificates Services Sign Up Log in
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
Tutorials PHP
Tutorial
Exercises
Java Tutorial
Certificates HTML Colors
Services
Java Reference
Sign Up Log in
C++ Tutorial Angular Reference
HTML
CSS jQuery Tutorial
JAVASCRIPT SQL PYTHON jQuery Reference
JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
Top Examples Get Certified
HTML Examples HTML Certificate
CSS Examples CSS Certificate
JavaScript Examples JavaScript Certificate
How To Examples Front End Certificate
SQL Examples SQL Certificate
Python Examples Python Certificate
W3.CSS Examples PHP Certificate
Bootstrap Examples jQuery Certificate
PHP Examples Java Certificate
Java Examples C++ Certificate
XML Examples C# Certificate
jQuery Examples XML Certificate
https://www.w3schools.com/sql/sql_update.asp 12/13
1/22/25, 5:55 PM SQL UPDATE Statement
Copyright 1999-2025 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
https://www.w3schools.com/sql/sql_update.asp 13/13