The WHERE
clause is used to filter records. It is used to extract only those records that fulfill a specified condition.
SELECT column1, column2, ...
FROM table_name
WHERE condition;
WHERE is just a condition statement. It can be used in UPDATE / DELETE, etc
SELECT * FROM Customers
WHERE Country='Mexico';
SELECT * FROM Customers
WHERE Price>30;
SELECT * FROM Customers
WHERE Price<30;
SELECT * FROM Customers
WHERE Price>=30;
SELECT * FROM Customers
WHERE Price<=30;
SELECT * FROM Customers
WHERE Price <> 30;
//In some SQL, the operator is !=
SELECT * FROM Customers
WHERE Price != 30;
Get data between a certain range
SELECT * FROM Customers
WHERE Price BETWEEN 50 AND 60
Search for a pattern
SELECT * FROM Customers
WHERE Price LIKE 's%'
To specify multiple possible values for a column