The SQL UPDATE Clause is used to modify the existing/update records in a table.

SYNTAX

89.png

Where,

  • UPDATE                                             : keyword used to update/modify the column values in table.

  • Table_name                                      : The name of the table from where you want to update the data

  • Column1Name, Column2Name         : The name of the columns of the table which you want to update

NOTE: We must always use the WHERE clause with the UPDATE query to modify the required rows, otherwise all the rows would be affected.

EXAMPLE

Let us consider a demo database with table name Persons.

90.png
91.png

The above Query updates the City Name where PersonId = 3;

92.png

Figure 27.2. UPDATE QUERY & OUTPUT;

 

Figure 27.1. Select * from Persons;

 

PRACTICE YOURSELF 

93.png