Mysql Update Statement
Mysql Update Statement
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C
UPDATE Syntax
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
Note: Be careful when updating records in a table! Notice the WHERE clause in the
UPDATE statement. The WHERE clause specifies which record(s) that should be updated.
If you omit the WHERE clause, all records in the table will be updated!
Demo Database
Below is a selection from the "Customers" table in the Northwind sample database:
CustomerID
Tutorials Exercises Services
CustomerName ContactName
Address City
Sign Up Log in
PostalCode
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C
1 Alfreds Maria Anders Obere Str. Berlin 12209
Futterkiste 57
UPDATE 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 selection from the "Customers" table will now look like this:
HTML
CSS helados
JAVASCRIPT SQL PYTHON JAVA2222PHP HOW TO W3.CSS C
The following SQL statement will update the PostalCode to 00000 for all records where
country is "Mexico":
Example
UPDATE Customers
SET PostalCode = 00000
WHERE Country = 'Mexico';
The selection from the "Customers" table will now look like this:
Update Warning!
Be careful when updating records. If you omit the WHERE clause, ALL records will be
updated!
Example
UPDATE Customers
SET PostalCode = 00000;
The selection from the "Customers" table will now look like this:
HTML
CSS JAVASCRIPT SQL PYTHON JAVAHanover
PHP HOW TO W3.CSS C
Sq.
Exercise:
Update the City column of all records in the Customers table.
Customers
City = 'Oslo';
Submit Answer »
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C
COLOR PICKER
Tutorials Exercises Services Sign Up Log in
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C
HTML
CSS CSS Tutorial
JAVASCRIPT SQL PYTHON CSS Reference PHP
JAVA HOW TO W3.CSS C
JavaScript Tutorial JavaScript Reference
How To Tutorial SQL Reference
SQL Tutorial Python Reference
Python Tutorial W3.CSS Reference
W3.CSS Tutorial Bootstrap Reference
Bootstrap Tutorial PHP Reference
PHP Tutorial HTML Colors
Java Tutorial Java Reference
C++ Tutorial Angular Reference
jQuery Tutorial jQuery Reference
FORUM ABOUT
W3Schools is optimized for learning and training. Examples might be simplified to
improve reading and learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we
cannot warrant full correctness
of all content. While using W3Schools, you agree to have read and accepted our terms of
use, cookie and privacy policy.
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C