SQL Questions and Answers – SQL Between Operator

This set of SQL Multiple Choice Questions & Answers (MCQs) focuses on “SQL Between Operator”.

1. Which of the following operator is used to retrieve values within a given range?
a) In
b) Like
c) Between
d) Range
View Answer

Answer: c
Explanation: BETWEEN operator allows us to easily test if an expression is within a range of values. This operator allows us to select only those rows that are within a specific range.

2. BETWEEN operator in SQL _____
a) Excludes starting and ending values
b) Includes starting value excludes ending value
c) Excludes starting value includes ending value
d) Includes starting and ending values
View Answer

Answer: d
Explanation: The BETWEEN operator selects values within a given range. This operator is inclusive, i.e. it includes both begin and end values of given range.

3. Which of the following operator has to be paired with BETWEEN in SQL?
a) Or
b) And
c) With
d) In
View Answer

Answer: b
Explanation: BETWEEN has to be paired with the AND operator in SQL to retrieve values that fall in a given specific range. Other than AND, no operator can be used with BETWEEN.
advertisement
advertisement

4. SQL BETWEEN operator is used with which of the following clause(s)?
a) Select
b) Where
c) Insert
d) Update
View Answer

Answer: b
Explanation: BETWEEN has to be paired with AND operator. It is always used in WHERE clause. It cannot be used with any other clauses in SQL.

5. BETWEEN operator can be used as a shorthand for which of the following operations?
a) >= AND <=
b) > AND <
c) >= OR <=
d) > OR <
View Answer

Answer: a
Explanation: BETWEEN is a logical operator which is used to return values that fall within a given range. This operator is inclusive, i.e. it includes both starting and ending values. It can be used as a shorthand for >= AND <=.

6. NOT BETWEEN is not a valid operator in SQL.
a) True
b) False
View Answer

Answer: b
Explanation: NOT BETWEEN is a valid operator in SQL. We can use the NOT BETWEEN operator to exclude a specific range of values from a database table.

7. Which of the following is a correct syntax for using BETWEEN operator?
a)

advertisement
SELECT column_list
FROM TABLE_NAME
WHERE column_name BETWEEN value1, value2;

b)

advertisement
SELECT column_list
FROM TABLE_NAME
WHERE column_name BETWEEN value1 AND value2;

c)

SELECT column_list
FROM TABLE_NAME
WHERE column_name BETWEEN value1 OR value2;

d)

SELECT column_list
FROM TABLE_NAME
WHERE column_name BETWEEN value1 AND value2 AND value3;
View Answer
Answer: b
Explanation: AND operator must be used with BETWEEN operator in SQL. No other comparison or logical operators can be used with BETWEEN. Range between any two values can be given at a time.

8. Consider the following query:

SELECT column_list
FROM TABLE_NAME
WHERE column_name BETWEEN max_value AND min_value;

This query returns which of the following records?
a) No records
b) Those records whose column_name values are >=min_value and <=max_value
c) Those records whose column_name values are >min_value and <max_value
d) Those records whose column_name values are >=min_value or <=max_value
View Answer

Answer: a
Explanation: BETWEEN a AND b in SQL implies the values which are >=a and <=b. In the given query a is max_value and b is min_value. So it has to return those records whose value is >=max_value and <=min_value, which is impossible. So, the query doesn’t return any records.

9. DATE values cannot be used with BETWEEN operators.
a) True
b) False
View Answer

Answer: b
Explanation: Numeric, text and date values can be used with BETWEEN operators in SQL. Using date fields with BETWEEN is similar to those of numeric and text field values.

10. Which of the following operator is used to exclude those records whose values fall in a given specific range of values?
a) Between
b) Not between
c) Not in
d) In
View Answer

Answer: b
Explanation: NOT BETWEEN is used to exclude the records whose values fall in a given specific range. In is used to specify multiple values in a WHERE clause. Not in is used to retrieve those records whose values are not in the specified list.

Sanfoundry Global Education & Learning Series – SQL.

To practice all areas of SQL, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.