0
0
SQLquery~10 mins

UPDATE multiple columns in SQL - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - UPDATE multiple columns
Start UPDATE statement
Specify table to update
Set new values for multiple columns
Apply WHERE condition to select rows
Execute update on selected rows
Finish and return number of rows updated
The UPDATE statement changes values in multiple columns for rows that meet the WHERE condition.
Execution Sample
SQL
UPDATE employees
SET salary = salary * 1.1, department = 'Sales'
WHERE department = 'Marketing';
This query increases salary by 10% and changes department to 'Sales' for employees in 'Marketing'.
Execution Table
StepActionRow IDOld salaryOld departmentNew salaryNew departmentCondition MetResult
1Check row10150000Marketing55000SalesYesUpdate applied
2Check row10260000Sales60000SalesNoNo update
3Check row10355000Marketing60500SalesYesUpdate applied
4Check row10470000HR70000HRNoNo update
5Finish------2 rows updated
💡 All rows checked; only rows with department 'Marketing' updated.
Variable Tracker
VariableStartAfter Row 101After Row 102After Row 103After Row 104Final
salary_101500005500055000550005500055000
department_101MarketingSalesSalesSalesSalesSales
salary_102600006000060000600006000060000
department_102SalesSalesSalesSalesSalesSales
salary_103550005500055000605006050060500
department_103MarketingMarketingMarketingSalesSalesSales
salary_104700007000070000700007000070000
department_104HRHRHRHRHRHR
Key Moments - 2 Insights
Why are only some rows updated and not all?
Only rows where the WHERE condition is true (department = 'Marketing') are updated, as shown in execution_table rows 1 and 3.
Does the UPDATE change columns not listed in SET?
No, only columns specified in SET are changed. Other columns keep their original values, as seen in rows 2 and 4 where no update occurs.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the new salary of row 103 after the update?
A60500
B55000
C60000
D70000
💡 Hint
Check the 'New salary' column for row 103 in the execution_table.
At which step does the condition 'department = Marketing' become false?
AStep 1
BStep 2
CStep 3
DStep 4
💡 Hint
Look at the 'Condition Met' column in execution_table for each step.
If the WHERE clause was removed, how would the execution table change?
AOnly rows with salary > 60000 would update
BNo rows would be updated
CAll rows would be updated
DOnly rows with department 'Sales' would update
💡 Hint
Without WHERE, UPDATE applies to all rows, so all would show 'Update applied' in the result.
Concept Snapshot
UPDATE multiple columns syntax:
UPDATE table_name
SET column1 = value1, column2 = value2
WHERE condition;
Only rows matching WHERE are updated.
Columns not listed remain unchanged.
Full Transcript
The UPDATE statement changes values in multiple columns for rows that meet the WHERE condition. In the example, employees in the Marketing department have their salary increased by 10% and their department changed to Sales. The execution table shows each row checked, whether it meets the condition, and if it is updated. Only rows 101 and 103 meet the condition and are updated. The variable tracker shows how salary and department values change step-by-step. Key moments clarify why only some rows update and that only specified columns change. The quiz tests understanding of the updated values, condition checks, and effects of removing the WHERE clause.