WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

SQL WHERE Clause


The WHERE clause is used to extract only those records that fulfill a specified criterion.


The SQL WHERE Clause 

WHERE is used to filter records

SQL WHERE Syntax

SELECT column_list
FROM table_name
WHERE condition;

Example Database

In this tutorial we will use the sample database.

Below is a selection from the "Customers" table:

CustomerID FastName city Country
1

Jhon Dallas United States
2 Eva Houston United States
3 Maria Texas USA
4

Rajesh Delhi India
5 Stephine Lule UK



WHERE Clause Example

The following SQL statement selects all the customers from the country "India", in the "Customers" table:

Example

SELECT * FROM Customers
WHERE Country='India';

Text Fields

When working with text columns, surround any text that appears in the statement with single quotation marks (').:

Example

SELECT * FROM Customers
WHERE Country=India;

Operators in The WHERE Clause

Comparison Operators and Logical Operators are used in the WHERE clause to filter the data to be selected.

The following operators can be used in the WHERE clause:

Operator Description
= Equal
<> Not equal. Note: !=
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
BETWEEN Between an inclusive range
LIKE Search for a pattern
IN To specify multiple possible values for a column