UPDATE statement is used to edit and modify the data in a table. Below showing the example for Update and Delete Statement.
Name | Income | Company | Position |
Angle | 4500 | Ajax Tech Limited | Manager |
Helen | 6900 | Programmingschools Limited | CEO |
Micheal | 4000 | SQLTutorial Limited | DBA |
Nick | 5000 | Programmingschools Limited | Programmer |
Table Name: Testing
SQL Statement With Example
UPDATE TESTING SET POSITION='BOSS' WHERE NAME='HELEN'
- Position Column updated from CEO to BOSS using the update statement with 1 condition name=helen.
Name | Income | Company | Position |
---|---|---|---|
Angle | 4500 | Ajax Tech Limited | Manager |
Helen | 6900 | Programmingschools Limited | BOSS |
Micheal | 4000 | SQLTutorial Limited | DBA |
Nick | 5000 | Programmingschools Limited | Programmer |
UPDATE TESTING SET POSITION='Head of Department' WHERE NAME='HELEN' AND COMPANY='Programmingschools Limited'
- Position Column updated from BOSS to Head of Department using the update statement with 2 condition name=helen and company=Programmingschools Limited.
Name | Income | Company | Position |
---|---|---|---|
Angle | 4500 | Ajax Tech Limited | Manager |
Helen | 6900 | Programmingschools Limited | Head of Department |
Micheal | 4000 | SQLTutorial Limited | DBA |
Nick | 5000 | Programmingschools Limited | Programmer |
DELETE Statement
DELETE FROM TESTING WHERE NAME='Angle'
-Delete row using delete statement with condition name=angle.
Name | Income | Company | Position |
---|---|---|---|
Helen | 6900 | Programmingschools Limited | Head of Department |
Micheal | 4000 | SQLTutorial Limited | DBA |
Nick | 5000 | Programmingschools Limited | Programmer |
DELETE FROM TESTING
-Whole table deleted
For more information for SELECT Statement, click here