strawquery PT
All lessons

Lesson 6 of 30

IN, NOT IN and BETWEEN

Today at the studio

It is review season, and every question now has a list or a range in it. "Only these genres." "Only people hired in those years." You are tired of typing OR.

The idea

IN (a, b, c) is a short way to write several OR tests on the same column. NOT IN keeps everything else.

BETWEEN low AND high keeps values from low to high, both ends included. It works for numbers, and for dates written as '2020-12-31', because that format sorts correctly as text.

Example

SELECT product FROM merch WHERE show_id IN (1, 2) AND units_sold BETWEEN 500 AND 1000

Your turn

0 of 4 questions

Question 1 of 4

Which shows are Fantasy or Sci-fi? Show title and genre, using IN.

Unofficial fan project. Titles belong to their creators and rights holders.