SQL OR Keyword
The OR operator is used in a WHERE clause to filter records where at least one of the given conditions is true.
SQL OR Syntax
SQL
x
1
SELECT column1, column2, ...
2
FROM table_name
3
WHERE condition1 OR condition2;
SQL OR with Patients Table Example
This query selects all patients whose gender is either ‘F'(Female)or whose last name is ‘Garcia’.
SQL
1
1
SELECT *
2
FROM Patients
3
WHERE gender = 'F' OR last_name = 'Garcia';

SQL OR with Appointments Table Example
This query selects all appointments scheduled either on ‘2023-11-15’ or with doctor_id equal to 2.
SQL
1
1
SELECT *
2
FROM Appointments
3
WHERE appointment_date = '2023-11-15' OR doctor_id = 2;
