SQL Update Statement

Table Of Contents:

  1. What Is SQL Update Statement?
  2. Syntax Of Update Statment.
  3. Examples Of Update Statement.

(1) What Is SQL Update Statement ?

  • The UPDATE statement is used to modify the existing records in a table.
  • If the user wants to update their records at a later point in time they can do that using the “UPDATE” statement.

(2) Syntax Of SQL Update Statement.

Syntax:

UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;

(3) Examples Of SQL Update Statement.

Demo Data:

Example-1: Updating A Single Record

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

Example-2: Updating Multiple Records

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

Example-3: Update Warning!

UPDATE Customers
SET ContactName='Juan';

Note:

  • Be careful when updating records. If you omit the WHERE clause, ALL records will be updated!

Leave a Reply

Your email address will not be published. Required fields are marked *