Concept Flow - UPDATE with WHERE condition
Start UPDATE statement
Check WHERE condition for each row
Update row
End UPDATE
The UPDATE command checks each row against the WHERE condition. If true, it updates that row; if false, it skips it.
UPDATE Employees SET Salary = Salary + 500 WHERE Department = 'Sales';
| Step | Row ID | Current Salary | Department | WHERE Condition (Department='Sales') | Action | New Salary |
|---|---|---|---|---|---|---|
| 1 | 101 | 3000 | Sales | True | Update | 3500 |
| 2 | 102 | 3200 | HR | False | Skip | 3200 |
| 3 | 103 | 2800 | Sales | True | Update | 3300 |
| 4 | 104 | 4000 | IT | False | Skip | 4000 |
| 5 | 105 | 3100 | Sales | True | Update | 3600 |
| 6 | - | - | - | - | End of rows | - |
| Row ID | Salary Before | Salary After |
|---|---|---|
| 101 | 3000 | 3500 |
| 102 | 3200 | 3200 |
| 103 | 2800 | 3300 |
| 104 | 4000 | 4000 |
| 105 | 3100 | 3600 |
UPDATE table_name SET column = new_value WHERE condition; - Only rows matching WHERE condition are updated. - Rows not matching are unchanged. - Omitting WHERE updates all rows.