SQL · Pattern 2 — Filtering Data
IN
IN (list) is shorthand for a chain of OR column = value checks against a fixed list — much easier to read (and write) than several ORs once the list grows past two or three values.
Source data — Pattern 2: Filtering Data
All queries run against the shared employees table (see schema.sql). This pattern also needs the manager_id column for topic 14 — not required back in Pattern 1. It also needs one row with salary < 50000 for topic 9, which Pattern 1's 6 rows didn't have — add:
INSERT INTO employees (employee_id, first_name, last_name, salary, department_id,
manager_id)
VALUES (7, 'Zoya', 'Khan', 42000, 500, 1);

What it does
IN (list) is shorthand for a chain of OR column = value checks against a fixed list — much easier to read (and write) than several ORs once the list grows past two or three values.
Problem
Find employees working in IT or HR.
SELECT *
FROM employees
WHERE department_id IN (100, 200); -- 100 = IT, 200 = HR
Result
