The WHERE clause is used to filter records. It is used to extract only those records that fulfill a specified condition.

Syntax

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

WHERE is just a condition statement. It can be used in UPDATE / DELETE, etc

Operators

Equal

SELECT * FROM Customers
WHERE Country='Mexico';

Greater/Less than [or equal]

SELECT * FROM Customers
WHERE Price>30;

SELECT * FROM Customers
WHERE Price<30;

SELECT * FROM Customers
WHERE Price>=30;

SELECT * FROM Customers
WHERE Price<=30;

Not equal

SELECT * FROM Customers
WHERE Price <> 30;

//In some SQL, the operator is !=
SELECT * FROM Customers
WHERE Price != 30;

BETWEEN

Get data between a certain range

SELECT * FROM Customers
WHERE Price BETWEEN 50 AND 60

LIKE

Search for a pattern

SELECT * FROM Customers
WHERE Price LIKE 's%'

IN

To specify multiple possible values for a column