Similar to AND, the OR operator can also be used to combine multiple conditions in WHERE, but there is a fundamental difference:

  • AND operator displays a row if all the conditions are true.
  • OR operator displays a row if any condition is true.

Suppose we want to check out a new movie or something action-packed:

SELECT * FROM movies WHERE year > 2014 OR genre = 'action';
  • year > 2014 is the 1st condition.

  • genre = 'action' is the 2nd condition.

  • OR combines the two conditions.

OR Venn Diagram

With OR, if any of the conditions are true, then the row is added to the result.



Let’s test this out:

SELECT * FROM movies WHERE year > 2014 OR genre = 'action';

Suppose we are in the mood for a good laugh or a good cry.

Using OR, write a query that returns all movies that are either a romance or a comedy.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?