0
0
MySQLquery~5 mins

UPDATE with WHERE clause in MySQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the UPDATE statement do in SQL?
The UPDATE statement changes existing data in a table. It modifies one or more rows based on given conditions.
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 the syntax of an UPDATE statement with a WHERE clause.
UPDATE table_name SET column1 = value1, column2 = value2 WHERE condition;
Click to reveal answer
intermediate
What happens if you run an UPDATE statement without a WHERE clause?
All rows in the table will be updated with the new values, which might cause unintended data changes.
Click to reveal answer
beginner
How can you update multiple columns in one UPDATE statement?
You list each column and its new value separated by commas after SET. For example: SET col1 = val1, col2 = val2.
Click to reveal answer
What does the WHERE clause do in an UPDATE statement?
ASpecifies new values for columns
BDeletes rows from the table
CCreates a new table
DLimits which rows are updated
What happens if you omit the WHERE clause in an UPDATE statement?
AAll rows in the table are updated
BNo rows are updated
COnly one row is updated
DThe table is deleted
Which of these is the correct syntax to update the 'price' column to 10 where 'id' equals 5?
ASET price = 10 WHERE id = 5 UPDATE products;
BUPDATE products WHERE id = 5 SET price = 10;
CUPDATE products SET price = 10 WHERE id = 5;
DUPDATE products price = 10 WHERE id = 5;
How do you update multiple columns in one UPDATE statement?
ASET col1 = val1, col2 = val2
BUPDATE col1 = val1, col2 = val2
CWHERE col1 = val1, col2 = val2
DSET col1 = val1 AND col2 = val2
Which keyword is mandatory to specify which rows to update?
AFROM
BWHERE
CSELECT
DJOIN
Explain how to safely update a specific row in a table using the UPDATE statement with a WHERE clause.
Think about how to avoid changing all rows accidentally.
You got /3 concepts.
    Describe what could happen if you forget the WHERE clause in an UPDATE statement.
    Consider the impact on the whole table.
    You got /3 concepts.