Complete the code to select all employees whose department is either 1, 2, or 3.
SELECT * FROM employees WHERE department_id [1] (1, 2, 3);
The IN operator checks if a value matches any value in a list. Here, it selects employees in departments 1, 2, or 3.
Complete the code to select all products that are not in categories 4, 5, or 6.
SELECT * FROM products WHERE category_id [1] (4, 5, 6);
The NOT IN operator selects rows where the value is not in the given list. Here, it excludes categories 4, 5, and 6.
Fix the error in the query to select customers from city 'New York' or 'Los Angeles'.
SELECT * FROM customers WHERE city [1] ('New York', 'Los Angeles');
The IN operator is used to check if the city is one of the listed cities. Using '=' would cause an error because it compares only one value.
Fill both blanks to select orders where the status is not 'shipped' or 'delivered'.
SELECT * FROM orders WHERE status [1] ('shipped', 'delivered') AND priority [2] 'high';
The first blank uses NOT IN to exclude 'shipped' and 'delivered' statuses. The second blank uses = to select orders with 'high' priority.
Fill all three blanks to select employees whose role is 'manager' or 'supervisor' and who work in department 10.
SELECT * FROM employees WHERE role [1] ('manager', 'supervisor') AND department_id [2] [3];
The first blank uses IN to select roles 'manager' or 'supervisor'. The second and third blanks together form = 10 to select department 10.