What is the WHERE clause?

Why Interviewers Ask This

Foundational questions like this help interviewers calibrate the rest of the interview. A confident, accurate answer signals that you have solid MySQL / SQL basics — a prerequisite for any developer role.

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.

Pro Tip

Back up your answer with a specific project or situation. Saying 'In my last MySQL / SQL project, I used this when...' immediately makes your answer more credible and memorable.