Challenge - 5 Problems
SQL Update Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Update a single column for specific rows
Given a table Employees with columns
Assume the original salary for
id, name, and salary, what will be the result of this query?UPDATE Employees SET salary = salary + 500 WHERE id = 3;Assume the original salary for
id = 3 is 3000.SQL
SELECT id, name, salary FROM Employees ORDER BY id;
Attempts:
2 left
💡 Hint
Only the row with
id = 3 will have its salary increased by 500.✗ Incorrect
The UPDATE statement changes the salary of the employee with
id = 3 by adding 500 to the current salary of 3000, resulting in 3500. Other rows remain unchanged.📝 Syntax
intermediate2:00remaining
Identify the syntax error in UPDATE statement
Which option contains a syntax error in updating a single column in the
Products table to set price to 20 where id is 5?Attempts:
2 left
💡 Hint
Check for missing operators or incorrect syntax in the SET clause.
✗ Incorrect
Option C is missing the '=' sign between the column name and the new value, causing a syntax error.
❓ optimization
advanced2:00remaining
Optimizing UPDATE for large tables
You want to increase the
stock column by 10 for all products in category 'Books' in a large Inventory table. Which query is the most efficient?Attempts:
2 left
💡 Hint
Focus on limiting the update only to relevant rows without unnecessary overhead.
✗ Incorrect
Option A directly updates only rows where category equals 'Books', which is efficient. Option A updates all rows unnecessarily. Option A uses LIKE which may be slower and less precise. Option A uses a subquery that is redundant and less efficient.
🔧 Debug
advanced2:00remaining
Why does this UPDATE not change any rows?
Given the table
Assume there is a user with username 'John_Doe' (capital J).
Users with columns id, username, and active, why does this query not update any rows?UPDATE Users SET active = 1 WHERE username = 'john_doe';Assume there is a user with username 'John_Doe' (capital J).
Attempts:
2 left
💡 Hint
Think about how string comparisons work in SQL by default.
✗ Incorrect
Most SQL databases treat string comparisons as case-sensitive by default, so 'john_doe' does not match 'John_Doe'. This causes no rows to be updated.
🧠 Conceptual
expert2:00remaining
Effect of UPDATE without WHERE clause
What happens if you run this query on the
Orders table?UPDATE Orders SET status = 'shipped';Attempts:
2 left
💡 Hint
Consider what happens when UPDATE is run without any filter.
✗ Incorrect
Without a WHERE clause, UPDATE affects every row in the table, setting the status column to 'shipped' for all orders.