SQLite OR Operator
The OR Operator
With OR, a record is returned if at least one of the conditions is true.
This example selects the customers from Germany or Spain:
More Than Two Conditions
This example selects the customers in Berlin, London or Paris:
Example
SELECT * FROM Customers
WHERE City = 'Berlin'
OR City = 'London'
OR City = 'Paris';
Try it Yourself »
Tip: When you compare one column with many values, IN is shorter. Read more in the SQLite IN chapter.
OR and AND Together
Use parentheses when you combine OR and AND. This example selects the products in category 1 or 2 that cost less than 15:
Example
SELECT * FROM Products
WHERE (CategoryID = 1 OR CategoryID = 2)
AND Price < 15;
Try it Yourself »
Without the parentheses, AND is done first, and you get a different result:
Example
SELECT * FROM Products
WHERE CategoryID = 1 OR CategoryID = 2
AND Price < 15;
Try it Yourself »