Recall & Review
beginner
What does the SQL UPDATE statement do?
The UPDATE statement changes existing data in a table by modifying one or more columns for rows that meet a specified condition.
Click to reveal answer
beginner
How do you update multiple columns in a single SQL UPDATE statement?
You list each column and its new value separated by commas after the SET keyword, like: SET column1 = value1, column2 = value2.
Click to reveal answer
beginner
Why should you always include a WHERE clause in an UPDATE statement?
Without a WHERE clause, the UPDATE will change all rows in the table, which might cause unintended data loss or errors.
Click to reveal answer
beginner
Example: Update the 'name' to 'Alice' and 'age' to 30 for the user with id 5. Write the SQL query.
UPDATE users SET name = 'Alice', age = 30 WHERE id = 5;
Click to reveal answer
beginner
Can you update columns to NULL using UPDATE? How?
Yes, you can set a column to NULL by assigning NULL as the value, for example: SET column_name = NULL.
Click to reveal answer
Which keyword is used to specify the columns to update in an SQL UPDATE statement?
✗ Incorrect
The SET keyword is used to list the columns and their new values in an UPDATE statement.
What happens if you omit the WHERE clause in an UPDATE statement?
✗ Incorrect
Without a WHERE clause, the UPDATE affects every row in the table.
How do you update two columns 'price' and 'stock' in one UPDATE statement?
✗ Incorrect
Multiple columns are updated by separating assignments with commas after SET.
Which of these is a valid UPDATE statement to change 'status' to 'active' and 'score' to 100 for user_id 7?
✗ Incorrect
The correct syntax uses commas to separate column assignments after SET.
Can you update a column to NULL in SQL?
✗ Incorrect
You can set any column to NULL by assigning NULL in the UPDATE statement.
Explain how to update multiple columns in a SQL table and why the WHERE clause is important.
Think about changing more than one detail at once and controlling which rows change.
You got /3 concepts.
Write an example SQL UPDATE statement that changes two columns for a specific row.
Use a simple table like users and columns like name and age.
You got /3 concepts.