OR Operator
The OR operator is used to combine multiple conditions in a SQL query. At least one of the conditions must be true for the overall expression to be true.
Example: Using OR
SELECT Name
FROM FreedomFighters
WHERE City = 'Chennai' OR Contribution = 'Education';
Output:
Returns the names of freedom fighters who are either from Chennai or contributed to education.
Do's and Don'ts
Do's
- Use
ORfor flexible filtering when at least one condition can be met. - Combine with
ANDusing parentheses to clarify precedence.
Don'ts
- Don't use
ORif all conditions must be true; useANDinstead. - Don't create complex
ORconditions without testing performance.