▶ Try SQL

SQL WHERE Clause

The WHERE clause filters records based on a condition.

The WHERE Clause

The WHERE clause is used to filter records — only rows that meet the condition are returned.

Syntax
SELECT column1, column2 FROM table_name WHERE condition;
Example — Filter by country
SELECT * FROM customers WHERE country = 'USA';

WHERE with Numbers

Number values do not need quotes:

Example — Filter by age
SELECT * FROM customers WHERE age > 30;

Operators in WHERE

OperatorDescriptionExample
=EqualWHERE age = 25
>Greater thanWHERE age > 30
<Less thanWHERE age < 40
>=Greater than or equalWHERE age >= 18
!=Not equalWHERE country != 'USA'
BETWEENWithin a rangeWHERE age BETWEEN 20 AND 35
LIKEPattern matchWHERE name LIKE 'A%'
INIn a listWHERE country IN ('USA', 'UK')

AND, OR, NOT

Example — AND
SELECT * FROM customers WHERE country = 'USA' AND age > 25;
Example — LIKE (starts with A)
SELECT * FROM customers WHERE name LIKE 'A%';