SQL Questions and Answers – SQL In Operator

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

Answer: c
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

Answer: a
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

Answer: b
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.
advertisement
advertisement

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

Answer: d
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

Answer: b
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)

advertisement
SELECT column_list
FROM TABLE_NAME
WHERE column_name IN VALUES;

c)

advertisement
SELECT column_list IN (VALUES)
FROM TABLE_NAME
WHERE column_name;

d)

SELECT column_list IN VALUES
FROM TABLE_NAME
WHERE column_name;
View Answer
Answer: a
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

Answer: a
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

Answer: c
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.

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.