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 OR for flexible filtering when at least one condition can be met.
  • Combine with AND using parentheses to clarify precedence.

Don'ts

  • Don't use OR if all conditions must be true; use AND instead.
  • Don't create complex OR conditions without testing performance.