SQL UPDATE Statement

The SQL UPDATE statement is used to update data in the table of a database.

SQL UPDATE statement

UPDATE table_name

SET column_name(s) = value(s)

WHERE column_name = value

When more than one row has the same value for a column, we can use the AND operator to specify additional column with value that is distinct. Just like below.

UPDATE table_name

SET column_name(s) = value(s)

WHERE column_name = value AND column_name = value


Database Table “Members”

Id FirstName LastName Email City Phone
1 Gilbert Duncan [email protected] Newark 973-600-3300
2 Elvis Daniels [email protected] Piscataway 862-600-3050
3 Michael Green [email protected] Detroit 732-500-5050
4 Kelvin Graham [email protected] Detroit 732-555-5050
5 Helsinko Getauchi [email protected]

SQL UPDATE Example

UPDATE Members

SET City=’Montreal’, Phone=’416-500-6565′

WHERE FirstName=’Helsinko’ AND LastName=’Getauchi’

RESULT of SQL UPDATE statement above will be

Id FirstName LastName Email City Phone
1 Gilbert Duncan [email protected] Newark 973-600-3300
2 Elvis Daniels [email protected] Piscataway 862-600-3050
3 Michael Green [email protected] Detroit 732-500-5050
4 Kelvin Graham [email protected] Detroit 732-555-5050
5 Helsinko Getauchi [email protected] Montreal 416-500-6565

Important: Please be very careful when using the SQL UPDATE statement. Make sure you specify what specific rows need to be updated by using the WHERE clause to restrict the row(s) because otherwise the whole table will be updated if no row is specified.