WHERE Clause — Filtering Data

In SQL, the WHERE clause lets you filter rows based on a condition.
Instead of getting all the data from a table, you can ask for just the rows that meet a specific rule.


Syntax

SELECT column1, column2, ... FROM table_name
WHERE condition;

Example: Show only employees from IT department

SELECT name, department FROM employees
WHERE department = 'IT';

This query returns only the rows where the department is IT.


Example: Show employees older than 30

SELECT name, age FROM employees
WHERE age > 30;

You can use comparison operators like:

OperatorDescription
=Equals
!=Not equal
>Greater than
<Less than
>=Greater than or equal to
<=Less than or equal to