This set of SQL Multiple Choice Questions & Answers (MCQs) focuses on “SQL In Operator”.
1. Which of the following operators allows us to specify multiple values in a WHERE clause?
a) Like
b) Between
c) In
d) Range
View Answer
Explanation: IN operator is used to check for values contained in a specific set of values. It allows us to specify multiple values in a WHERE clause.
2. IN operator can be used as shorthand for which of the following operators?
a) Multiple OR
b) Multiple Like
c) Multiple NOT
d) Multiple Between
View Answer
Explanation: IN operator is used to remove the need of multiple OR condition in SELECT, INSERT, UPDATE or DELETE. It can be used as a shorthand for multiple OR operators.
3. IN operator is used with which of the following clause(s)?
a) Select
b) Where
c) Update
d) Insert
View Answer
Explanation: The IN operator allows us to specify multiple values in a WHERE clause. Using this operator we can easily test if the expression matches any value in the list of values.
4. Which type of arguments can be used with IN operator?
a) Character values only
b) Numeric values only
c) Date type only
d) Any data type
View Answer
Explanation: Any type of arguments, i.e. character, numeric, date etc. types can be used with IN operator. Character fields must be enclosed in single quotes.
5. NOT IN is not a valid operator in SQL.
a) True
b) False
View Answer
Explanation: The IN operator is used to compare a value to a list of literal values that have been specified and returns those rows which satisfies the given condition(s). NOT IN is a valid operator in SQL which is used to exclude the rows our list.
6. Which of the following is a correct syntax for IN operator?
a)
SELECT column_list FROM TABLE_NAME WHERE column_name IN (VALUES);
b)
SELECT column_list FROM TABLE_NAME WHERE column_name IN VALUES;
c)
SELECT column_list IN (VALUES) FROM TABLE_NAME WHERE column_name;
d)
SELECT column_list IN VALUES FROM TABLE_NAME WHERE column_name;
Explanation: The SQL IN operator allows us to test if an expression matches any value in a list of values. Syntax for using IN operator is:
SELECT column_list FROM TABLE_NAME WHERE column_name IN (VALUES);
7. Any number of values can be listed in an IN operator.
a) True
b) False
View Answer
Explanation: A list of values can be listed in an IN operator. The IN operator compares a value to a set of values separated by commas and retrieves matching rows from the table.
8. Which of the following statement(s) can be used in place of list of values in an IN operator?
a) Insert
b) Update
c) Select
d) Modify
View Answer
Explanation: A select statement can be substituted in place of values list in an IN operator. Values retrieved by that select statement is used as values list of IN operator. Value retrieved from select statement should match with the field mentioned in where clause.
Sanfoundry Global Education & Learning Series – SQL.
To practice all areas of SQL, here is complete set of 1000+ Multiple Choice Questions and Answers.