<-- Chapter 18: SQL INSERT
Chapter 19
SQL UPDATE
UPDATE statement is used to update existing table data in database table with the help of WHERE clause.WHERE clause tells which record is to be updated.
Lets see an example from the below table "employees" :-
employee_id |
name |
code |
designation |
salary |
101 |
ABC |
E-101 |
Engineer |
12000 |
102 |
DEF |
E-102 |
Doctor |
8000 |
103 |
GHI |
E-103 |
Software Developer |
8000 |
104 |
JKL |
E-104 |
CEO |
12000 |
105 |
MNO |
E-105 |
Software Developer |
100000 |
UPDATE SQL Statement Syntax :-
UPDATE tablename
SET column1 = value1, column2 = value2, column3 = value3,,,
WHERE column = value;
UPDATE statement example :-
UPDATE `employees`
SET `salary` = 40000
WHERE employee_id = 102;
Now Run this Query, we will see the output below :-
employee_id |
name |
code |
designation |
salary |
101 |
ABC |
E-101 |
Engineer |
12000 |
102 |
DEF |
E-102 |
Doctor |
40000 |
103 |
GHI |
E-103 |
Software Developer |
8000 |
104 |
JKL |
E-104 |
CEO |
12000 |
105 |
MNO |
E-105 |
Software Developer |
100000 |
We can see here, One existing record with Employee Id 102 is updated. salary column value for this record is updated to 40000 .
Chapter 20: SQL DELETE -->
0 Comment(s)