Beginner

18. OR Operator

Learn how the OR operator allows a record to satisfy any one of multiple conditions.

📘 Lesson 18 of 728 ⏱ 7 min 🎯 Beginner

The OR operator is a logical operator used to combine multiple conditions in SQL. Unlike AND, which requires every condition to be true, OR returns a row when at least one of the specified conditions is true. OR is useful when a business requirement allows multiple possible values or conditions.

Many real-world questions require alternatives rather than conditions that must all be true. For example, a manager may want employees from either Finance or HR. OR allows the query to return both groups.

Find employees who work in either Finance or HR.

SQL
SELECT
    EmployeeName,
    Department
FROM Employees
WHERE Department = 'Finance'
OR Department = 'HR';

OR is used for customer segmentation, department filtering, regional analysis, product filtering, transaction analysis, and business reporting.

  • OR combines multiple conditions.
  • At least one OR condition must be true.
  • OR is commonly used with WHERE.
  • OR is useful for alternative conditions.
  • Parentheses may be important when mixing AND and OR.
What does OR do in SQL?

OR returns a row when at least one of the combined conditions is true.

What is the difference between AND and OR?

AND requires all conditions to be true, while OR requires at least one condition to be true.

Have you finished this lesson?

Introduction to SQL – All Lessons