SQL - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

SQL Update

SQL Update

shape Description

By using SQL Update command, the column values can be updated i.e, changing the name of the employee and increasing/decreasing the salary. And the column parameters specifies the name of the columns of the table and the datatypes parameters specifies the type of data that the column is holding that may varies from varchar, decimal, date and integers.

shape Conceptual figure

shape Syntax

Update<table_name> set <column_name>=value where <condition>;
Table_name => Any accurate table. condition =>condition is a logic to get a specific record.

shape Examples

By viewing the below example, the concept of update command can be easily understand. [c]sql> select * from employee; +--------+-------+-------+ | emp_id | ename | sal | +--------+-------+-------+ | 1001 | maddi | 12000 | | 1002 | jack | 13000 | +--------+-------+-------+ 2 rows in set (0.00 sec) sql> update employee set sal=sal+100 where ename='jack'; Query OK, 1 row affected (0.03 sec) Rows matched: 1 Changed: 1 Warnings: 0 sql> select * from employee; +--------+-------+-------+ | emp_id | ename | sal | +--------+-------+-------+ | 1001 | maddi | 12000 | | 1002 | jack | 13100 | +--------+-------+-------+ 2 rows in set (0.00 sec) sql> update employee set ename='james' where emp_id=1001; Query OK, 1 row affected (0.03 sec) Rows matched: 1 Changed: 1 Warnings: 0 sql> select * from employee; +--------+-------+-------+ | emp_id | ename | sal | +--------+-------+-------+ | 1001 | james | 12000 | | 1002 | jack | 13100 | +--------+-------+-------+ 2 rows in set (0.00 sec)[/c] The above example tells how to update the existing data from the table. i.e before updating the salary it was 13000 and after updating the result is 13100. And in another example the user will change the ename values from maddi to james.

Summary

shape Key Points

  • SQL Update Command - Update command is utilized to update the estimations of a current table values or protests.