The UPDATE statement is used to Update Existing record in Database Table.
The basic syntax is as follows:
UPDATE Table_Name SET Column1='value1', column2='value2' WHERE some_column='some_value'
We have Employee Table
Emp_id | Name | Surname | Salary | Dept_id |
1 | Rajesh | Khanna | 45000 | 2 |
2 | Sneha | Gupta | 55000 | 4 |
3 | Sandeep | Nehte | 95000 | 1 |
4 | Kirti | Patil | 25000 | 3 |
5 | Nilesh | Jadhav | 45000 | 3 |
6 | Dipesh | Das | 35000 | 5 |
7 | Kailash | Rane | 62000 | 1 |
8 | Kavita | Deshpande | 48000 | 3 |
9 | Sanjay | Datt | 50000 | 3 |
10 | Shruti | Hasan | 78000 | 1 |
Now we want to update this table, by updating the salary 25000 to 30000 of employee Name 'Kirti'
Syntax For SQL:
UPDATE Employee SET Salary='30,000' WHERE Name='Kirti'
Emp_id | Name | Surname | Salary | Dept_id |
1 | Rajesh | Khanna | 45000 | 2 |
2 | Sneha | Gupta | 55000 | 4 |
3 | Sandeep | Nehte | 95000 | 1 |
4 | Kirti | Patil | 30000 | 3 |
5 | Nilesh | Jadhav | 45000 | 3 |
6 | Dipesh | Das | 35000 | 5 |
7 | Kailash | Rane | 62000 | 1 |
8 | Kavita | Deshpande | 48000 | 3 |
9 | Sanjay | Datt | 50000 | 3 |
10 | Shruti | Hasan | 78000 | 1 |
After Execute:
(1 row(s) affected)
(0 ms taken)
(1 row(s) affected)
(0 ms taken)
No comments:
Post a Comment