How to use UPDATE Command in SQL
In this post, you will learn how to use UPDATE command in SQL.UPDATE command is used to update existing record in table. Update command is always used with WHERE clause. If you don't use WHERE Clause, all record will be updated in table so while using UPDATE command, you must be carefull.
Syntax of UPDATE command:
UPDATE Table_Name SET Column_Name='New_Values'
WHERE Column_Name='Old_Values' ;
Suppose we have source table:
Now i'm going to update Emp_Name: Mohan to "Mahesh". Now use below code to Update existing record
UPDATE EMP
SET Emp_Name='Mahesh' WHERE Emp_Name='Mohan';
Now after executing this code, you will get below results:
Update Multiple Values by using below command
UPDATE EMP
SET Emp_Name='Mahesh' , Emp_Age=30, Emp_Salary=30000 WHERE Emp_ID=1;
Now Output will be :