0
0
MySQLquery~20 mins

UPDATE with WHERE clause in MySQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
UPDATE Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the output after this UPDATE?
Consider a table Employees with columns id, name, and salary. Initially, the table has:
1, 'Alice', 5000
2, 'Bob', 6000
3, 'Charlie', 7000

What will be the salary of Bob after running this query?
UPDATE Employees SET salary = salary + 500 WHERE name = 'Bob';
A6500
B5500
C7000
D6000
Attempts:
2 left
💡 Hint
The WHERE clause limits which rows get updated.
📝 Syntax
intermediate
2:00remaining
Which UPDATE query is syntactically correct?
Choose the correct MySQL UPDATE statement that increases salary by 1000 for employees with salary less than 6000.
AUPDATE Employees SET salary = salary + 1000 WHERE salary < 6000;
BUPDATE Employees salary = salary + 1000 WHERE salary < 6000;
CUPDATE Employees SET salary + 1000 WHERE salary < 6000;
DUPDATE Employees SET salary = salary + 1000 salary < 6000;
Attempts:
2 left
💡 Hint
Remember the syntax: UPDATE table SET column = value WHERE condition;
optimization
advanced
2:00remaining
Which UPDATE query is more efficient for updating multiple rows?
You want to increase salary by 500 for all employees in department 'Sales'. The table has an index on the department column.
Which query is more efficient?
AUPDATE Employees SET salary = salary + 500 WHERE department LIKE '%Sales%';
BUPDATE Employees SET salary = salary + 500 WHERE department = 'Sales';
CUPDATE Employees SET salary = salary + 500;
DUPDATE Employees SET salary = salary + 500 WHERE department != 'Sales';
Attempts:
2 left
💡 Hint
Using indexed columns in WHERE clause improves performance.
🔧 Debug
advanced
2:00remaining
What error does this UPDATE query raise?
Given a table Products with columns id, name, and price, what error occurs when running:
UPDATE Products SET price = price + 10 WHERE;
ARuntime error: column 'price' not found
BNo error, updates all rows
CSyntax error near 'WHERE;'
DType error: cannot add integer to price
Attempts:
2 left
💡 Hint
Check the WHERE clause syntax.
🧠 Conceptual
expert
2:00remaining
What happens if UPDATE has no WHERE clause?
If you run:
UPDATE Employees SET salary = salary + 1000;

What is the effect on the table?
ASyntax error due to missing WHERE clause
BOnly rows with NULL salary are updated
CNo rows are updated
DAll rows have their salary increased by 1000
Attempts:
2 left
💡 Hint
Think about what happens when WHERE is omitted.