SQL Questions and Answers – SQL Exists

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

1. Which operator is used to check the existence of a record in a subquery?
a) In
b) Exists
c) Check
d) For
View Answer

Answer: b
Explanation: The EXISTS condition in SQL is used to check whether the result of a correlated nested query is empty or not. It is used to test for the existence of a record in a subquery.

2. The result of EXISTS is _______
a) A numerical value
b) A character
c) A Boolean value
d) A query
View Answer

Answer: c
Explanation: The result of EXISTS is a Boolean value. It returns true if the subquery returns one or more records and false if the subquery returns no records.

3. The EXISTS operator returns true if the subquery returns no records.
a) True
b) False
View Answer

Answer: b
Explanation: EXISTS is a Boolean operator used in a subquery to test whether the inner query returns any row. It returns true if the subquery returns one or more rows.
advertisement
advertisement

4. EXISTS condition is used in combination with which of the following?
a) Subquery
b) Constant
c) Column name
d) Expression
View Answer

Answer: a
Explanation: The SQL EXISTS operator is used along with a subquery and is said to be met if the subquery returns at least one row. It can be used with a constant, column name or an expression.

5. How many records must be matched with the given criteria to return TRUE from EXISTS condition in SQL?
a) One
b) Two
c) Three
d) Four
View Answer

Answer: a
Explanation: When EXISTS is used, it returns TRUE as soon as it finds any record that matches the given criteria. So, to return TRUE at least one record should satisfy the given criteria.

6. EXISTS operator is used with WHICH of the following clause(s)?
a) Select
b) In
c) Where
d) Group by
View Answer

Answer: c
Explanation: The EXISTS Operator check the Subquery for rows existence, and if there are any then it will return TRUE otherwise FALSE. It is used along with WHERE clause in SQL.

7. What is the basic syntax of EXISTS operator in SQL?
a)

advertisement
SELECT column_list
FROM TABLE_NAME
WHERE COLUMN EXISTS (subquery);

b)

advertisement
SELECT column_list
FROM TABLE_NAME
WHERE EXISTS (subquery);

c)

SELECT column_list
FROM TABLE_NAME
WHERE TABLE_NAME EXISTS (subquery);

d)

SELECT column_list
FROM TABLE_NAME
COLUMN EXISTS (subquery);
View Answer
Answer: b
Explanation: The basic syntax of EXISTS operator in SQL is:
Select column_list
From table_name
Where EXISTS (subquery)

8. The process of sub query execution repeat as many number of times as there are main query rows when EXISTS operator is used.
a) True
b) False
View Answer

Answer: a
Explanation: When EXISTS operator is used, the process of inner query execution repeats as many times as there are outer query rows. If there are ten rows that can result from main query, the subquery will be executed ten times.

9. EXISTS operator can be prefixed with which of the following operators?
a) In
b) Not
c) Like
d) Between
View Answer

Answer: b
Explanation: EXISTS operator cannot be prefixed using In, Like or between operators. NOT operator can be used as a prefix for EXISTS operator.

10. The WHERE clause with NOT EXISTS operator is satisfied if how many rows are returned by the subquery?
a) One
b) Two
c) Zero
d) All
View Answer

Answer: c
Explanation: NOT EXISTS operator returns true if no records are returned by the subquery and false if at least one record is returned by the sub query.

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.