SQL UPDATE statement is used to modify the existing records in a table. Which record  is to be update it is decided by a condition. To specify condition, we use WHERE clause. If you used WHERE clause with UPDATE query to update selected records otherwise , all the records would be affected.

Syntax:

The basic syntax of UPDATE query with WHERE clause is as follows:

UPDATE table_name
SET column1 = value1, column2 = value2...., columnN= valueN
WHERE [condition];

 

Example:

 

The PRODUCT table having the following records:


SQL UPDATE STATEMENT


Following example, which would update ProductName for a Product which ID is 1.

 

UPDATE PRODUCT SET ProductName='Acer Laptop' where ProductId=1

 

Now, Product table would have the following records:


SQL UPDATE STATEMENT

Note: You can also update multiple columns at a time to the selected records.


Thanks.


0 comments


Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

You may also like