0
0
MySQLquery~10 mins

UPDATE with WHERE clause in MySQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to update the salary of employees in the 'employees' table.

MySQL
UPDATE employees SET salary = 5000 WHERE id = [1];
Drag options to blanks, or click blank then click option'
Aemployee_id
Bsalary
C10
D'10'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around numeric IDs causes errors.
Using wrong column names in WHERE clause.
2fill in blank
medium

Complete the code to update the 'status' to 'active' for users with last login before 2023-01-01.

MySQL
UPDATE users SET status = 'active' WHERE last_login < [1];
Drag options to blanks, or click blank then click option'
A'2023-01-01'
B2023-01-01
C'01-01-2023'
D2023/01/01
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around the date.
Using wrong date format.
3fill in blank
hard

Fix the error in the UPDATE statement to change the 'price' to 19.99 for product with id 5.

MySQL
UPDATE products SET price = [1] WHERE id = 5;
Drag options to blanks, or click blank then click option'
A'19.99'
Bprice
C19,99
D19.99
Attempts:
3 left
💡 Hint
Common Mistakes
Putting numeric values in quotes.
Using comma instead of dot for decimals.
4fill in blank
hard

Fill both blanks to update the 'quantity' to 100 for items where 'category' is 'books'.

MySQL
UPDATE inventory SET [1] = 100 WHERE [2] = 'books';
Drag options to blanks, or click blank then click option'
Aquantity
Bcategory
Cprice
Dstock
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up column names in SET and WHERE clauses.
Using wrong column names that don't exist.
5fill in blank
hard

Fill all three blanks to update the 'status' to 'inactive' for users with 'last_login' before '2022-12-31' and 'role' equals 'guest'.

MySQL
UPDATE users SET [1] = 'inactive' WHERE [2] < [3] AND role = 'guest';
Drag options to blanks, or click blank then click option'
Astatus
Blast_login
C'2022-12-31'
Dusername
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the date string.
Using wrong column names in SET or WHERE.