Skip to content

SQL OR Operator

Syntax

The OR operator in SQL is used to combine two or more conditions. At least one condition must be TRUE for a row to be included in the result.

SELECT column1, column2
FROM table_name
WHERE condition1 OR condition2;

Example

-- Using a single OR
SELECT name, department
FROM employees
WHERE department = 'HR' OR department = 'Sales';
/* Output:
| name | department |
|------------|------------|
| John Doe | Sales |
| Alice Brown| HR |
*/
-- Using two ORs
SELECT name, department
FROM employees
WHERE department = 'HR' OR department = 'Sales' OR age > 40;
/* Output:
| name | department |
|-------------|------------|
| John Doe | Sales |
| Alice Brown | HR |
*/