SQL · Pattern 2 — Filtering Data
Logical Operators (AND, OR, NOT)
AND requires every condition to be true, OR requires at least one, and NOT inverts a condition.
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
AND requires every condition to be true, OR requires at least one, and NOT inverts a condition. Combining them lets one WHERE clause express a rule with multiple parts — just watch operator precedence (AND binds tighter than OR; use parentheses when mixing them).
Problem
Find IT employees earning more than ₹70,000.
SELECT *
FROM employees
WHERE department_id = 100 -- 100 = IT
AND salary > 70000;
Result
