Log in from a computer to take this course

You'll need to log in from a computer to start Learn SQL. But you can practice or keep up your coding streak with the Codecademy Go app. Download the app to get started.

apple storegoogle store
Learn

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.

Instructions

1.

Let’s test this out:

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

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?