Complete the code to select all employees who work in departments listed in the subquery.
SELECT * FROM employees WHERE department_id [1] (SELECT department_id FROM departments WHERE location = 'New York');
The IN operator is used to check if a value matches any value in a list or subquery result.
Complete the code to find all products whose category_id is in the list of categories with 'Electronics' in their name.
SELECT product_name FROM products WHERE category_id [1] (SELECT category_id FROM categories WHERE category_name LIKE '%Electronics%');
The IN operator allows filtering products whose category_id matches any category_id returned by the subquery.
Fix the error in the query to select customers who have orders in the 'Pending' status.
SELECT customer_name FROM customers WHERE customer_id [1] (SELECT customer_id FROM orders WHERE status = 'Pending');
The IN operator is needed because the subquery returns multiple customer_ids, and we want to check if the customer_id is among them.
Fill both blanks to select orders where the product_id is in the list of products priced above 100.
SELECT order_id, product_id FROM orders WHERE product_id [1] (SELECT product_id FROM products WHERE price [2] 100);
The IN operator checks if product_id is among those returned by the subquery. The subquery filters products with price greater than 100 using the '>' operator.
Fill all three blanks to select employee names who work in departments located in 'Chicago' and have a salary greater than 50000.
SELECT employee_name FROM employees WHERE department_id [1] (SELECT department_id FROM departments WHERE location = [2]) AND salary [3] 50000;
The first blank uses IN to check if the employee's department_id is in the list of departments in Chicago. The second blank is the string 'Chicago' to match the location. The third blank uses > to filter salaries greater than 50000.