SQL - Update
The update clause updates column values of a table. Update requires a conditional statement to select the row to be updated.
SQL Code:
UPDATE employees
SET Lastname = 'Fletcher', Firstname = 'Ron'
WHERE id = '11';
SQL Table:
| ID | Lastname | Firstname | Title |
| 11 | Fletcher | Ron | manager |
Here we changed record 11, our manager, to a new manager.
SQL - Updating Multiple Rows
With the use of expressions and operators, update allows for the manipulation of several rows at once.
SQL Code:
UPDATE employees
SET Title = UPPER(Title);
SQL Table:
| ID | Lastname | Firstname | Title |
| 1 | Johnson | David | CREW |
| 2 | Hively | Jessica | CREW |
| 9 | Hicks | Freddy | CREW |
| 10 | Harris | Joel | CREW |
| 11 | Davis | Julie | MANAGER |
Using the UPPER expression we changed our Title field to all capital letters. Update also supports the use of subqueries.
|