The WHERE clause is how SQL filters rows — instead of getting every record in a table back from a SELECT statement, you describe a condition, and only rows that satisfy it are returned. It's the difference between "show me all employees" and "show me only the employees in Engineering earning over $90,000."

WHERE works with SELECT, UPDATE, and DELETE statements alike — anywhere SQL needs to know which rows to act on, WHERE is how you tell it.

Basic Syntax

SELECT name, department, salary
FROM employees
WHERE department = 'Engineering';

Result:

name | department | salary
--------------|--------------|--------
Alice Chen | Engineering | 95000.00
Priya Nair | Engineering | 88000.00

Comparison Operators

WHERE accepts the usual comparison operators — =, != (or <>), <, >, <=, >= — and these can be combined with AND/OR, covered in more depth in comparison and logical operators.

SELECT name, salary
FROM employees
WHERE salary >= 90000;

Result:

name | salary
--------------|--------
Alice Chen | 95000.00

Combining Multiple Conditions

Real filters usually need more than one condition. Use AND when every condition must be true, and OR when any one of them is enough:

SELECT name, department, salary
FROM employees
WHERE department = 'Engineering' AND salary > 90000;

Result:

name | department | salary
--------------|--------------|--------
Alice Chen | Engineering | 95000.00

A Common Mistake: Filtering vs Grouping

A frequent point of confusion for beginners is that WHERE cannot filter on an aggregate result like COUNT() or SUM() — for that, you need HAVING, which runs after rows have been grouped. WHERE filters individual rows before any grouping happens; HAVING filters groups after. This distinction matters once you get to GROUP BY later in this course, where the two work together.

Mastering WHERE unlocks almost everything else — once you can reliably describe "which rows," the rest of SQL is mostly about what to do with them: sort them, group them, join them to other tables, or change them.