OR

Published Jun 11, 2021Updated Aug 18, 2022
Contribute to Docs

The OR operator tests if any condition in a given expression evaluates to TRUE.

Syntax

SELECT column_name
FROM table_name
WHERE condition1
  OR condition2
  ...
  OR conditionN;

If any of the condition_s evaluate to TRUE, the row(s) can be returned. However, if all of the condition_s were to evaluate to NOT TRUE, then the row(s) would not be returned from the query.

Example 1

To query for records where item_name is equal to 'brush' or 'gloves' in the inventory table:

SELECT *
FROM inventory
WHERE item_name = 'brush' OR 'gloves';

Example 2

To query for records where item_name is equal to 'plunger' or 'soap' or 'wipes' in the inventory table:

SELECT *
FROM inventory
WHERE item_name= 'plunger' OR 'soap' OR 'wipes';

All contributors

Looking to contribute?

Learn SQL on Codecademy