UPDATE Query in SQL

Back to home
Logicmojo - Updated Aug 28, 2021



What is Update Query in SQL?

The UPDATE Query in SQL is used to update existing records in a table. If you use the WHERE clause with the Change query, you can update only the rows you want, rather than all of them.


Update Query Syntax

UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE  condition

Example Query to understand Update Query

Let's understand this by taking one example,


Query :

UPDATE Student
SET Age = 21
WHERE  Roll_no = 7


Output


Hence, the age of Yashi gets updated to 21.


Update Multiple Records

The number of records that will be updated is determined by the WHERE clause.


Let's understand this by taking one example,


Query :

UPDATE Student
SET Age = 21
WHERE  Age = 20;


Output


Hence, the age of Riya and Yashi gets updated to 21.


With this article at Logicmojo, you must have the complete idea of Update Query in SQL.