The UPDATE statement changes existing data in a table. It modifies one or more columns for rows that match a condition.
Click to reveal answer
beginner
How do you update a single column in SQL?
Use UPDATE table_name SET column_name = new_value WHERE condition; to change one column's value in rows that meet the condition.
Click to reveal answer
beginner
Why is the WHERE clause important in an UPDATE statement?
The WHERE clause limits which rows get updated. Without it, all rows in the table will be changed.
Click to reveal answer
beginner
Write an example SQL query to update the salary column to 5000 for employees with id 3.
Example: UPDATE employees SET salary = 5000 WHERE id = 3;
Click to reveal answer
intermediate
What happens if you run UPDATE employees SET salary = 5000; without a WHERE clause?
All rows in the employees table will have their salary set to 5000, which might not be what you want.
Click to reveal answer
Which SQL keyword is used to change data in a table?
ASELECT
BUPDATE
CINSERT
DDELETE
✗ Incorrect
The UPDATE keyword modifies existing data in a table.
What does the WHERE clause do in an UPDATE statement?
ASpecifies which rows to update
BSpecifies which columns to update
CCreates a new table
DDeletes rows
✗ Incorrect
The WHERE clause limits the rows affected by the update.
How do you update only the price column in a table named products?
AUPDATE products SET price = new_value;
BUPDATE products WHERE price = new_value;
CSELECT price FROM products;
DUPDATE products SET price = new_value WHERE condition;
✗ Incorrect
You must use SET to specify the column and WHERE to limit rows.
What happens if you omit the WHERE clause in an UPDATE?
AAll rows are updated
BOnly one row is updated
CNo rows are updated
DThe query fails
✗ Incorrect
Without WHERE, all rows in the table are updated.
Which of these is a valid SQL update statement for a single column?
AUPDATE table SET (column = value);
BUPDATE table WHERE id = 1 SET column = value;
CUPDATE table SET column = value WHERE id = 1;
DUPDATE table (column) VALUES (value);
✗ Incorrect
The correct syntax is UPDATE table SET column = value WHERE condition;.
Explain how to update a single column in a SQL table safely.
Think about how to change only certain rows without affecting the whole table.
You got /4 concepts.
What could happen if you forget the WHERE clause in an UPDATE statement?
Consider the impact on the entire table.
You got /4 concepts.
Practice
(1/5)
1. What does the SQL statement UPDATE employees SET salary = 5000 WHERE id = 3; do?
easy
A. It changes the salary to 5000 for the employee with id 3.
B. It adds a new employee with salary 5000 and id 3.
C. It deletes the employee with id 3.
D. It shows the salary of employee with id 3.
Solution
Step 1: Understand the UPDATE statement
The UPDATE command changes existing data in a table.
Step 2: Analyze the SET and WHERE clauses
SET salary = 5000 changes the salary column, WHERE id = 3 limits the change to the employee with id 3.
Final Answer:
It changes the salary to 5000 for the employee with id 3. -> Option A
Quick Check:
UPDATE with SET and WHERE changes specified rows [OK]
Hint: UPDATE changes data; SET picks column; WHERE picks rows [OK]
Common Mistakes:
Thinking UPDATE adds new rows
Forgetting WHERE updates all rows
Confusing UPDATE with SELECT
2. Which of the following is the correct syntax to update the price column to 20 in the products table for product with id 10?
easy
A. UPDATE products SET price = 20 WHERE id = 10;
B. UPDATE products price = 20 WHERE id = 10;
C. UPDATE products SET price WHERE id = 10 = 20;
D. UPDATE products SET price = 20;
Solution
Step 1: Check the UPDATE syntax
The correct syntax is UPDATE table_name SET column = value WHERE condition;
Step 2: Validate each option
UPDATE products SET price = 20 WHERE id = 10; matches the correct syntax with SET and WHERE clauses properly used.
Final Answer:
UPDATE products SET price = 20 WHERE id = 10; -> Option A
Quick Check:
Correct UPDATE syntax uses SET column = value and WHERE [OK]
Hint: Always use SET column = value and WHERE condition [OK]
Common Mistakes:
Omitting SET keyword
Placing WHERE before SET
Missing semicolon at end
3. Given the table students with columns id, name, and grade, what will be the result of this query?
UPDATE students SET grade = 90 WHERE name = 'Alice';
Assuming the table before update:
id | name | grade
1 | Alice | 85
2 | Bob | 88
3 | Alice | 92
medium
A. No rows will be updated because name is not unique.
B. Only the first row with name 'Alice' will be updated.
C. Both rows with name 'Alice' will have grade updated to 90.
D. All rows in the table will have grade set to 90.
Solution
Step 1: Understand the WHERE clause effect
WHERE name = 'Alice' matches all rows where name is exactly 'Alice'.
Step 2: Apply UPDATE to matching rows
Both rows with name 'Alice' (id 1 and 3) will have their grade set to 90.
Final Answer:
Both rows with name 'Alice' will have grade updated to 90. -> Option C
Quick Check:
UPDATE affects all rows matching WHERE condition [OK]
Hint: WHERE filters all matching rows, not just one [OK]
Common Mistakes:
Assuming only one row updates with non-unique WHERE
Thinking UPDATE without WHERE updates one row
Confusing UPDATE with SELECT
4. Identify the error in this SQL statement:
UPDATE orders SET status 'shipped' WHERE order_id = 101;
medium
A. Incorrect table name.
B. Missing equal sign (=) between column and value.
C. Using single quotes around column name.
D. Missing WHERE clause.
Solution
Step 1: Check SET clause syntax
SET clause must have column = value format. Here, equal sign is missing.
Step 2: Verify other parts
WHERE clause is present, table name looks correct, and no quotes around column name.
Final Answer:
Missing equal sign (=) between column and value. -> Option B
Quick Check:
SET requires column = value syntax [OK]
Hint: SET needs column = value, not just column value [OK]
Common Mistakes:
Omitting equal sign in SET
Forgetting WHERE causes all rows update
Using quotes incorrectly around column names
5. You have a table inventory with columns item_id, quantity, and price. You want to increase the price by 10% only for items with quantity less than 5. Which SQL statement correctly updates the price column?
hard
A. UPDATE inventory SET price = price + 10 WHERE quantity < 5;
B. UPDATE inventory SET price = price + 0.10 WHERE quantity < 5;
C. UPDATE inventory SET price = price * 0.10 WHERE quantity < 5;
D. UPDATE inventory SET price = price * 1.10 WHERE quantity < 5;
Solution
Step 1: Understand the requirement
Increase price by 10% means multiply price by 1.10.
Step 2: Check the WHERE condition
Only update rows where quantity is less than 5.
Step 3: Evaluate each option
UPDATE inventory SET price = price * 1.10 WHERE quantity < 5; correctly multiplies price by 1.10 with proper WHERE clause.
Final Answer:
UPDATE inventory SET price = price * 1.10 WHERE quantity < 5; -> Option D
Quick Check:
Multiply price by 1.10 to increase by 10% [OK]
Hint: Multiply price by 1.10 to increase by 10% [OK]
Common Mistakes:
Adding 10 instead of 10%
Multiplying by 0.10 reduces price
Adding 0.10 increases price by 0.10 units only
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.