BETWEEN and IN in a WHERE clause

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

BETWEEN and IN in a WHERE clause

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which query returns students with 100 to 120 points, including both 100 and 120?
A SELECT * FROM students WHERE points BETWEEN 100, 120;
B SELECT * FROM students WHERE points BETWEEN 100 AND 120;
2. A student has exactly 120 points. Does WHERE points BETWEEN 100 AND 120 include them?
A No, BETWEEN stops just before 120
B Yes, BETWEEN includes both limits
3. Which WHERE clause does the same job as: yearLevel = 7 OR yearLevel = 9 OR yearLevel = 10?
A WHERE yearLevel IN (7, 9, 10)
B WHERE yearLevel BETWEEN (7, 9, 10)
4. Which query finds students in the Red or Blue house using IN?
A SELECT * FROM students WHERE house IN ('Red', 'Blue');
B SELECT * FROM students WHERE house IN 'Red', 'Blue';
5. Which query leaves out products in the Tech and Sport categories?
A SELECT * FROM products WHERE category NOT IN ('Tech', 'Sport');
B SELECT * FROM products WHERE category IN NOT ('Tech', 'Sport');

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1WHERE mark BETWEEN 60 AND 80 AWHERE house NOT IN ('Red', 'Blue')
2WHERE house IN ('Red', 'Blue') BWHERE yearLevel IN (7, 9, 10)
3IN replaces repeated OR conditions on the same field CKeeps rows where house is Red or Blue, matching any value in the list
4NOT IN excludes every value in the list DBETWEEN needs the keyword AND between the low and high values, not a comma. It should be BETWEEN 5 AND 20.
5WHERE price BETWEEN 5, 20 EKeeps rows where mark is from 60 to 80, including both 60 and 80
6WHERE house IN 'Red', 'Blue' FThe list after IN must be inside brackets. It should be IN ('Red', 'Blue').

Definitions

BETWEEN low AND high

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
SELECT firstName, points FROM students WHERE points _______ 90 AND 120;
2.
SELECT firstName FROM students WHERE yearLevel BETWEEN 7 ___ 8;
3.
SELECT firstName, house FROM students WHERE house __ ('Red', 'Blue');
4.
SELECT firstName, yearLevel FROM students WHERE yearLevel ______ (7, 8);
5.
SELECT name, price FROM products WHERE ________ IN ('Tech', 'Sport');

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A SELECT firstName, points
B FROM students
C WHERE points
D BETWEEN 120 AND 100;
Question 2
A SELECT name, price
B FROM products
C WHERE price BETWEEN 2, 10;
Question 3
A SELECT firstName, house
B FROM students
C WHERE house IN 'Red','Blue';
Question 4
A SELECT * FROM products
B WHERE stock IN NOT (0, 5);
C ORDER BY name;
Question 5
A SELECT FROM products WHERE
B price BETWEEN 5 AND 20;
C ORDER BY price;

Answer Key

BETWEEN and IN in a WHERE clause
Section A: Quick Questions
Q1
B — SELECT * FROM students WHERE points BETWEEN 100 AND 120;
Q2
B — Yes, BETWEEN includes both limits
Q3
A — WHERE yearLevel IN (7, 9, 10)
Q4
A — SELECT * FROM students WHERE house IN ('Red', 'Blue');
Q5
A — SELECT * FROM products WHERE category NOT IN ('Tech', 'Sport');
Section B: Match the Pairs
Q1
WHERE mark BETWEEN 60 AND 80 → Keeps rows where mark is from 60 to 80, including both 60 and 80
Q2
WHERE house IN ('Red', 'Blue') → Keeps rows where house is Red or Blue, matching any value in the list
Q3
IN replaces repeated OR conditions on the same field → WHERE yearLevel IN (7, 9, 10)
Q4
NOT IN excludes every value in the list → WHERE house NOT IN ('Red', 'Blue')
Q5
WHERE price BETWEEN 5, 20 → BETWEEN needs the keyword AND between the low and high values, not a comma. It should be BETWEEN 5 AND 20.
Q6
WHERE house IN 'Red', 'Blue' → The list after IN must be inside brackets. It should be IN ('Red', 'Blue').
Section C: Definitions
Q1
BETWEEN low AND high — Tests if a value is inside a range, including both limits. Its partner IN (a, b, c) checks a value against a list, replacing repeated OR. NOT IN excludes the list.
Section D: Fill in the Blanks
Q1
SELECT firstName, points FROM students WHERE points BETWEEN 90 AND 120;
Q2
SELECT firstName FROM students WHERE yearLevel BETWEEN 7 AND 8;
Q3
SELECT firstName, house FROM students WHERE house IN ('Red', 'Blue');
Q4
SELECT firstName, yearLevel FROM students WHERE yearLevel NOT IN (7, 8);
Q5
SELECT name, price FROM products WHERE category IN ('Tech', 'Sport');
Section E: Spot the Error
Q1
D — BETWEEN needs the low value first and the high value second. With 120 AND 100 no number can fit the range, so no rows come back. It should be BETWEEN 100 AND 120.
Q2
C — BETWEEN joins its low and high limits with the keyword AND, not a comma. It should be BETWEEN 2 AND 10.
Q3
C — The list after IN must be inside brackets. It should be IN ('Red','Blue').
Q4
B — The keywords are in the wrong order. NOT comes before IN, so it should be NOT IN (0, 5).
Q5
A — SELECT must say which fields to show. The * is missing, so it should be SELECT * FROM products WHERE.