UPDATE Statement in SQL

Let’s understand Update Statement in SQL. In SQL,  UPDATE statement is used to update the records or data present in the table.

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 WHERE clause the SQL UPDATE command can change all the records for the specific columns of a table.

SQL Syntax : 

SQL > UPDATE table_name
SET column1=value1, column2=value2,…
WHERE some_column = some_value;


Update Statement in SQL with Example

Let’s see the example of the UPDATE statement. Let’s Update the Salary of ‘John’ in emp table.

SQL> Update Emp

          SET Salary = 100000

         Where First_Name = ‘John’;

The above query will update the salary of John. If you will omit the Where condition in above query then It will update the salary of all employees present in the emp salary.


SQL update Multiple Columns

We can update data only in specific columns.

SQL> Update Emp

          SET Salary = 100000, Dept_Id = 102, Mngr_Id = 50

         Where First_Name = ‘John’;


SQL Update Columns with NULL

In below example, We will see how NULL works with the Update query.

SQL > UPDATE  Employees

           SET phone_no=NULL  

           WHERE commission >= 1.15;  


0 Comment

Leave a Reply