Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
See the whole table
Select some columns
Filtering rows
Logic
11. The BETWEEN operator
Text patterns
To be or NULL to be
A little bit of mathematics
Let's practice

Instruction

Good. Now, if you want to find users whose age is between 13 and 70, you can of course use the previous example:

SELECT id, name
FROM user
WHERE age <= 70
  AND age >= 13;

But there is also another way of writing the example above. Take a look:

SELECT id, name
FROM user
WHERE age BETWEEN 13 AND 70;

We introduced a new keyword BETWEEN which simply means that we look for rows with the age column set to be anything between 13 and 70, including these values.

Exercise

Select the vin, brand, and model columns of all cars which were produced between 1995 and 2005.

Stuck? Here's a hint!

Type:

SELECT
  vin,
  brand,
  model
FROM car
WHERE production_year BETWEEN 1995 AND 2005;