AdvancedWHERE & Filtering
Filter with complex multi-condition logic using brackets
The query
SQL
SELECT emp_id, first_name, salary, dept_id, status
FROM employees
WHERE
(dept_id IN (1, 2, 3) AND salary > 70000)
OR
(dept_id = 4 AND salary > 50000 AND status = 'active')
ORDER BY dept_id, salary DESC;Note
“Use parentheses to control evaluation order with complex AND/OR combinations.