0
0
MySQLquery~5 mins

BETWEEN range filtering in MySQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the SQL BETWEEN operator do?
The BETWEEN operator filters results to include only values within a specified range, including the start and end values.
Click to reveal answer
beginner
Write a simple SQL query using BETWEEN to find ages between 18 and 30.
Example: <br>SELECT * FROM users WHERE age BETWEEN 18 AND 30;<br>This returns users aged 18 through 30 inclusive.
Click to reveal answer
beginner
Does BETWEEN include the boundary values in the range?
Yes, BETWEEN includes both the start and end values in the range.
Click to reveal answer
intermediate
How is BETWEEN different from using >= and <=?
Using BETWEEN a AND b is the same as value >= a AND value <= b. BETWEEN is just a shorter, clearer way to write it.
Click to reveal answer
beginner
Can BETWEEN be used with dates in MySQL?
Yes, BETWEEN works with dates to filter rows between two dates, including both dates.
Click to reveal answer
Which of the following queries correctly selects rows where the price is between 100 and 200?
ASELECT * FROM products WHERE price BETWEEN 100 AND 200;
BSELECT * FROM products WHERE price > 100 AND price < 200;
CSELECT * FROM products WHERE price >= 100 OR price <= 200;
DSELECT * FROM products WHERE price = 100 AND price = 200;
Does BETWEEN include the boundary values in the range?
AIt includes only the lower boundary.
BNo, it excludes both boundaries.
CYes, it includes both boundaries.
DIt includes only the upper boundary.
Which is equivalent to value BETWEEN 10 AND 20?
Avalue = 10 OR value = 20
Bvalue &gt; 10 AND value &lt; 20
Cvalue &gt;= 10 OR value &lt;= 20
Dvalue &gt;= 10 AND value &lt;= 20
Can BETWEEN be used to filter date ranges in MySQL?
ANo, it only works with numbers.
BYes, it works with dates.
COnly with datetime, not date.
DOnly with strings.
What happens if you write WHERE value BETWEEN 20 AND 10?
AIt returns no rows because the range is invalid.
BIt returns all rows.
CIt swaps the values automatically.
DIt returns rows where value is between 10 and 20.
Explain how the BETWEEN operator works in SQL and give an example query.
Think about filtering values within a range.
You got /3 concepts.
    Describe the difference between using BETWEEN and using >= and <= operators.
    Consider how you write conditions for a range.
    You got /3 concepts.