Challenge - 5 Problems
UPDATE Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Effect of UPDATE without WHERE clause
Consider a table Employees with columns
Assume the table initially has 3 rows with salaries 3000, 4000, and 5000.
id, name, and salary. What will be the result after running this query?UPDATE Employees SET salary = salary + 1000;Assume the table initially has 3 rows with salaries 3000, 4000, and 5000.
SQL
UPDATE Employees SET salary = salary + 1000;
Attempts:
2 left
💡 Hint
Think about what happens if you don't limit which rows to update.
✗ Incorrect
Without a WHERE clause, UPDATE affects every row in the table. So all employees get their salary increased by 1000.
❓ query_result
intermediate2:00remaining
UPDATE with incorrect WHERE condition
Given a table Products with columns
Assume only one product has category 'Electronics' but its price is 900.
product_id, price, and category, what will be the result of this query?UPDATE Products SET price = price * 0.9 WHERE category = 'Electronics' AND price > 1000;Assume only one product has category 'Electronics' but its price is 900.
SQL
UPDATE Products SET price = price * 0.9 WHERE category = 'Electronics' AND price > 1000;
Attempts:
2 left
💡 Hint
Check if any product matches both conditions in WHERE.
✗ Incorrect
The WHERE clause requires category 'Electronics' and price > 1000. Since no product meets both, no rows are updated.
📝 Syntax
advanced2:00remaining
Identify the syntax error in UPDATE statement
Which option contains a syntax error in the UPDATE statement?
Attempts:
2 left
💡 Hint
Look for missing keywords or punctuation.
✗ Incorrect
Option B is missing the keyword SET before the column assignment, causing a syntax error.
🔧 Debug
advanced2:00remaining
Unexpected data change after UPDATE
A developer runs this query:
But after running it, the quantity for all products decreased by 1. What is the most likely cause?
UPDATE Inventory SET quantity = quantity - 1 WHERE product_id = 101;But after running it, the quantity for all products decreased by 1. What is the most likely cause?
Attempts:
2 left
💡 Hint
Think about what happens if WHERE clause is ignored or wrong.
✗ Incorrect
If WHERE is missing or wrong, UPDATE affects all rows, causing all quantities to decrease.
🧠 Conceptual
expert2:00remaining
Why must UPDATE be used with caution in multi-user environments?
In a busy database with many users, why is it important to be cautious when running UPDATE statements?
Attempts:
2 left
💡 Hint
Consider how databases handle multiple users changing data at the same time.
✗ Incorrect
UPDATE can lock data to keep it consistent, but this can block other users and cause delays or deadlocks.