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
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
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
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.
4. SQL BETWEEN operator is used with which of the following clause(s)?
a) Select
b) Where
c) Insert
d) Update
View Answer
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
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
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)
SELECT column_list FROM TABLE_NAME WHERE column_name BETWEEN value1, value2;
b)
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;
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
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
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
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.