SQL Commands : UPDATE

The UPDATE command is used to modify the existing records in a table. We also need to use the WHERE clause with the UPDATE statement to update the selected rows, otherwise all the rows would be affected. The basic syntax of the UPDATE statement with WHERE clause is as follows :
UPDATE table_name SET column_name1 = value, column_name2 = value, ... column_nameN = value WHERE [condition];
At above we can also combine two more conditions using AND or the OR operators. The table we are going to use in this example is :

UPDATE employee SET salary = 8000, Addr = 'NewYark' WHERE EmpName = 'John';
After running the above query, employee table will be :

If we want to modify all the salary column values in the employee table, then we do not need to use the WHERE clause, for example :
UPDATE employee SET salary = 10000;
Now the employee table will be :

Next Topic :