SQL OR
Anonymous contributor
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 inventoryWHERE 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 inventoryWHERE item_name= 'plunger' OR 'soap' OR 'wipes';
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn SQL on Codecademy
- Learn to analyze data with SQL and prepare for technical interviews.
- Includes 9 Courses
- With Certificate
- Beginner Friendly.18 hours
- Learn how to query SQL databases and design relational databases to efficiently store large quantities of data.
- Includes 5 Courses
- With Certificate
- Beginner Friendly.13 hours