Introduction

UPDATE statement is used to modify the existing rows in a table. It is used with WHERE clause to update only specific records.

Syntax

UPDATE table_name
SET
    column1 = new_value1,
    column2 = new_value2,
    ...
WHERE
    condition;

To update data in a table

  • Specify the table name in the UPDATE clause.
  • Assign a new value for the column to update. To update data in multiple columns, each column value pair is separated by a comma (,).
  • Specify which rows to update in the WHERE clause. It is an optional clause. Each rows in the table will be updated if this clause is not used.

Example

Consider below table

Employee Information Table
Employee Information Table
/* Update first name of record having id 4*/
UPDATE employleinfo SET firstName='New Name' WHERE id=4

Reference

Update (SQL)