0
0
MySQLquery~10 mins

IN and NOT IN operators 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 select all employees whose department is either 1, 2, or 3.

MySQL
SELECT * FROM employees WHERE department_id [1] (1, 2, 3);
Drag options to blanks, or click blank then click option'
AIN
BNOT IN
C=
DLIKE
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' instead of 'IN' which only compares one value.
Using 'LIKE' which is for pattern matching, not lists.
2fill in blank
medium

Complete the code to select all products that are not in categories 4, 5, or 6.

MySQL
SELECT * FROM products WHERE category_id [1] (4, 5, 6);
Drag options to blanks, or click blank then click option'
ABETWEEN
BNOT IN
C=
DIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'IN' instead of 'NOT IN' which would select only those categories.
Using '=' which only compares one value.
3fill in blank
hard

Fix the error in the query to select customers from city 'New York' or 'Los Angeles'.

MySQL
SELECT * FROM customers WHERE city [1] ('New York', 'Los Angeles');
Drag options to blanks, or click blank then click option'
ANOT IN
BLIKE
CIN
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' which only compares one value and causes an error with multiple values.
Using 'LIKE' which is for pattern matching, not lists.
4fill in blank
hard

Fill both blanks to select orders where the status is not 'shipped' or 'delivered'.

MySQL
SELECT * FROM orders WHERE status [1] ('shipped', 'delivered') AND priority [2] 'high';
Drag options to blanks, or click blank then click option'
ANOT IN
BIN
C=
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'IN' instead of 'NOT IN' in the first blank.
Using '!=' instead of '=' in the second blank.
5fill in blank
hard

Fill all three blanks to select employees whose role is 'manager' or 'supervisor' and who work in department 10.

MySQL
SELECT * FROM employees WHERE role [1] ('manager', 'supervisor') AND department_id [2] [3];
Drag options to blanks, or click blank then click option'
AIN
BNOT IN
C10
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'NOT IN' for roles which would exclude managers and supervisors.
Swapping '=' and '10' positions or missing one of them.