What is the WHERE clause?

Answer

The WHERE clause filters rows returned by SELECT, or affected by UPDATE/DELETE, based on a condition. Only rows where the condition evaluates to TRUE are included. Examples: WHERE age > 18, WHERE status = "active", WHERE email IS NOT NULL. Operators: Comparison: =, !=, <>, <, >, <=, >= ; Range: BETWEEN 18 AND 65 (inclusive); List: IN ("active", "pending"), NOT IN (...); Pattern matching: LIKE "John%" (% = any characters, _ = one character), NOT LIKE; NULL check: IS NULL, IS NOT NULL (never use = NULL); Logical: AND, OR, NOT. Combining conditions: WHERE age > 18 AND (status = "active" OR role = "admin"). Important: WHERE is evaluated BEFORE GROUP BY and aggregate functions — use HAVING to filter on aggregated values.