0
0
SQLquery~10 mins

UPDATE single column in SQL - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - UPDATE single column
Start
Identify Table
Set new value for one column
Apply WHERE condition?
NoUpdate all rows
Yes
Update matching rows
End
The UPDATE command changes values in one column of a table, optionally filtering rows with WHERE.
Execution Sample
SQL
UPDATE employees
SET salary = 60000
WHERE employee_id = 3;
This updates the salary of the employee with ID 3 to 60000.
Execution Table
StepActionEvaluationResult
1Identify table 'employees'Table foundReady to update
2Set 'salary' = 60000Prepare new valueValue ready
3Check WHERE employee_id = 3Row 1: employee_id=1 -> FalseSkip row 1
4Check WHERE employee_id = 3Row 2: employee_id=2 -> FalseSkip row 2
5Check WHERE employee_id = 3Row 3: employee_id=3 -> TrueUpdate row 3 salary to 60000
6Check WHERE employee_id = 3Row 4: employee_id=4 -> FalseSkip row 4
7Finish updateAll rows checkedUpdate complete
💡 All rows checked, only row with employee_id=3 updated
Variable Tracker
VariableStartAfter Step 3After Step 5Final
salary (row 1)50000500005000050000
salary (row 2)52000520005200052000
salary (row 3)58000580006000060000
salary (row 4)49000490004900049000
Key Moments - 2 Insights
Why does only one row get updated even though we set salary = 60000?
Because the WHERE condition filters rows. Only the row where employee_id = 3 matches and gets updated, as shown in execution_table rows 3 to 6.
What happens if we omit the WHERE clause?
Without WHERE, all rows get updated. The execution_table would skip the condition checks and update every row's salary.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the salary of employee_id=3 after step 5?
A58000
B60000
C52000
D49000
💡 Hint
Check the 'Result' column at step 5 where the update happens.
At which step does the update command skip a row because the WHERE condition is false?
AStep 3
BStep 5
CStep 7
DStep 2
💡 Hint
Look at the evaluation for row 1 in the execution_table.
If the WHERE clause is removed, how would the execution_table change?
AOnly the first row would be updated.
BNo rows would be updated.
CAll rows would be updated without condition checks.
DThe update would fail with an error.
💡 Hint
Refer to the key moment about omitting WHERE clause.
Concept Snapshot
UPDATE table_name
SET column_name = new_value
[WHERE condition];

- Changes one column's value
- WHERE filters which rows update
- Without WHERE, all rows update
Full Transcript
The UPDATE single column command changes values in one column of a table. It starts by identifying the table, then prepares the new value. It checks each row against the WHERE condition. Only rows matching the condition get updated. Others stay the same. If no WHERE is given, all rows update. This example updates salary to 60000 for employee_id 3 only.