The OR operator combines conditions and returns TRUE when at least one of the conditions is satisfied.
OR is useful when a business requirement allows multiple possible conditions.
Find employees working in either IT or Finance.
SELECT
EmployeeName,
Department
FROM Employees
WHERE Department = 'IT'
OR Department = 'Finance';
OR is commonly used for category selection, exception reporting, customer segmentation, and multi-option business rules.
- OR combines multiple conditions.
- At least one condition must be TRUE.
- It is commonly used with WHERE.
- Multiple OR conditions can be combined.
- Parentheses are useful when mixing AND and OR.
What does OR do in SQL?
OR returns TRUE when at least one of the connected conditions is satisfied.
When should OR be used?
OR should be used when records matching any one of several conditions should be included.