Tell Me
 

Modifying Data

Previous previous|next Next Page

During everyday operations in a company, data constantly requires changes. You can make changes to existing records in a table by performing an UPDATE operation. While performing an UPDATE, you need to specify the column(s) and row that you are modifying as well as the new value(s).



Syntax

UPDATE [table] SET  column1 = value1, column2 = value2 ...)

 		WHERE colunm1 = value1 AND column2 = value2

Example: Simple UPDATE

UPDATE EMPLOYEES SET SALARY = SALARY * 1.05 

      	WHERE EMPLOYEE_ID = 7499

      

Example: Using Sub-query

UPDATE EMPLOYEES SET SALARY = SALARY * 1.05 

      	WHERE DEPARTMENT_ID = (SELECT DEPARTMENT_ID FROM DEPARTMENTS WHERE DEPARTMENT_NAME = ’SALES’)