TechnoLearnAcademy

TECHNOLEARN

SQL UPDATE Statement

The UPDATE statement in SQL is used to modify existing records in a table based on a specified condition. It allows you to         change the values of one or more columns in the rows that match the condition.

Syntax:      

                UPDATE table_name                                                                                                                                                                          SET column1 = value1 , column2 = value2, …                                                                                                                                  WHERE condition(s);
Note: If you omit the where clause, all rows in the table will be updated.
Let’s understand the update statement with an example. For demonstration purposes, we will be using the table emp.
         Table Emp

Example:

   Objective: In this example, We will update the location of the ecode 1007 from Florida to Texas. 
                       UPDATE Tbl_Emp                                                                                                                                                                               SET Location = ‘Texas’                                                                                                                                                                       WHERE Ecode = 1007;

Example:

   Objective: In this example, We will update the location of the ecode 1008 from Florida to Texas and the department to                           Sales.
                       UPDATE Tbl_Emp                                                                                                                                                                               SET Location = ‘Texas’ , Department = ‘Sales’                                                                                                                                 WHERE Ecode = 1007;
Scroll to Top