SQLite WHERE Clause
The WHERE Clause
The WHERE clause filters the records. Only the records that match the condition are returned.
This example selects all the customers from Mexico:
Note: WHERE is also used in UPDATE and DELETE statements, to choose which records to change or delete.
Text and Numbers
Text values must be in single quotes. Numbers are written without quotes:
Single Quotes, Not Double Quotes
In SQLite, double quotes are for the names of tables and columns. "Mexico" in double quotes means a column named Mexico.
Some SQLite programs accept text in double quotes anyway, but others give an error. Always write text in single quotes, like 'Mexico'.
Operators in the WHERE Clause
You can use these operators in a condition:
| Operator | Description |
|---|---|
= | Equal |
> | Greater than |
< | Less than |
>= | Greater than or equal |
<= | Less than or equal |
<> or != | Not equal |
BETWEEN | Between two values |
LIKE | Search for a pattern |
IN | One of several values |
This example selects the products with a price greater than 30:
This example selects all the customers that are not from Germany: