sql logo

Learning SQL - Updating Data

The UPDATE keyword is used to update data in a database. UPDATE can be used to change multiple pieces of data and you can use the WHERE keyword to change specific data.

UPDATE Syntax:

UPDATE <table_name>

SET <column_name> = value, <column_name> = value

UPDATE Syntax with WHERE:

UPDATE <table_name>

SET <column_name> = value, <column_name> = value

WHERE condition

Example(s):

There is an error with the year_released column for Taxi Driver. It was released in 1976 not 1975.

movies data

This is how you do the update:

UPDATE movies

SET year_released = 1976

WHERE title = 'Taxi Driver'

movie data

If you did not use the WHERE keyword this is what would happen.

UPDATE movies

SET year_released = 1976

movies data without WHERE keyword