SQL update statement
Update statement
Once there is some data in the table, it may be required to modify the data. To do so, the SQL UPDATE command can be used. It changes the records in tables.
The SQL UPDATE command changes the data which already exists in the table. Usually, it is needed to make a conditional UPDATE in order to specify which row(s) are going to be updated.
The WHERE clause is used to make the update restricted and the updating can happen only on the specified rows.
Without using any WHERE clause (or without making any restriction) the SQL UPDATE command can change all the records for the specific columns of a table.
Syntax:
UPDATE < table name > SET<column1>=<value1>,<column2>=<value2>,..... WHERE <condition>;
Parameters:
Name | Description |
---|---|
table_name | Name of the table to be updated. |
column1,column2 | Name of the columns of the table. |
value1,value2 | New values. |
condition | Condition(s) using various functions and operators. |
Syntax diagram - UPDATE STATEMENT

SQL update for a specific column
Data for a specific column(s) can be changed with the SQL UPDATE statement.
Example:
Sample table: neworder
To change the value of 'ord_description' of 'neworder' table with 'ZOD', the following SQL statement can be used :
SQL Code:
UPDATE neworder
SET ord_description='ZOD';
Here is a new document which is a collection of questions with short and simple answers, useful for learning SQL as well as for interviews.
Check out our 1000+ SQL Exercises with solution and explanation to improve your skills.
Want to improve the above article? Contribute your Notes/Comments/Examples through Disqus.
Previous: Insert using nested subqueries with any operator
Next: Update with condition
SQL: Tips of the Day
CASE statement in a JOIN condition?
SELECT * FROM sys.indexes i JOIN sys.partitions p ON i.index_id = p.index_id JOIN sys.allocation_units a ON CASE WHEN a.type IN (1, 3) AND a.container_id = p.hobt_id THEN 1 WHEN a.type IN (2) AND a.container_id = p.partition_id THEN 1 ELSE 0 END = 1
Ref: https://bit.ly/3KxZyUq
- Weekly Trends
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
- JavaScript functions Exercises
- Python Tutorial
- Python Array Exercises
- SQL Cross Join
- C# Sharp Array Exercises