Challenge - 5 Problems
Master of Multiple Column Updates
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the output after updating multiple columns?
Given the table Employees with columns
Assuming the initial row with
id, name, salary, and department, what will be the result of this query?UPDATE Employees SET salary = salary + 500, department = 'HR' WHERE id = 3;
Assuming the initial row with
id = 3 is {id: 3, name: 'Alice', salary: 3000, department: 'Sales'}, what will be the updated row?SQL
UPDATE Employees SET salary = salary + 500, department = 'HR' WHERE id = 3;
Attempts:
2 left
💡 Hint
Remember that both columns are updated in the same query for the rows matching the condition.
✗ Incorrect
The query increases salary by 500 and changes department to 'HR' for the employee with id 3. So salary becomes 3000 + 500 = 3500 and department changes from 'Sales' to 'HR'.
🧠 Conceptual
intermediate2:00remaining
Which SQL statement correctly updates multiple columns?
You want to update the
price and stock columns in a Products table for the product with product_id = 10. Which of the following SQL statements is correct?Attempts:
2 left
💡 Hint
The SET clause lists columns and their new values separated by commas.
✗ Incorrect
Option A uses the correct syntax: UPDATE table SET column1 = value1, column2 = value2 WHERE condition. Other options have syntax errors.
🔧 Debug
advanced2:00remaining
Identify the error in this UPDATE statement for multiple columns
Consider this SQL statement:
What error will this query produce?
UPDATE Orders SET status = 'Shipped' stock = stock - 1 WHERE order_id = 100;
What error will this query produce?
Attempts:
2 left
💡 Hint
Check the syntax between multiple column assignments in the SET clause.
✗ Incorrect
Multiple columns in SET must be separated by commas. Missing comma causes syntax error.
❓ optimization
advanced2:00remaining
Optimizing multiple column updates in a large table
You need to update the
status and last_updated columns for 10,000 rows in a large Tasks table. Which approach is generally better for performance?Attempts:
2 left
💡 Hint
Minimize the number of UPDATE statements to reduce overhead.
✗ Incorrect
A single UPDATE statement that changes multiple columns is more efficient than multiple separate updates or row-by-row updates.
❓ query_result
expert3:00remaining
What is the final state after a complex multiple column UPDATE?
Given the table Inventory with columns
What will be the row after running this query?
item_id, quantity, price, and discount, and initial row:{item_id: 5, quantity: 100, price: 10, discount: 0}What will be the row after running this query?
UPDATE Inventory SET quantity = quantity - 20, price = price * 0.9, discount = discount + 5 WHERE item_id = 5;
SQL
UPDATE Inventory SET quantity = quantity - 20, price = price * 0.9, discount = discount + 5 WHERE item_id = 5;
Attempts:
2 left
💡 Hint
Calculate each column update step by step.
✗ Incorrect
Quantity decreases by 20 (100 - 20 = 80), price is multiplied by 0.9 (10 * 0.9 = 9), discount increases by 5 (0 + 5 = 5).