In SQL, IN and EXISTS are used for subquery comparisons, but they work differently. IN compares a value against a static list, while EXISTS checks for the presence of rows from a subquery. Understanding the difference is essential for writing optimised and correct SQL queries.
Time limit: 0
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Which one uses a correlated subquery more efficiently?
Correct
Incorrect
Question 4 of 15
4. Question
What does EXISTS return if the subquery has 0 rows?
Correct
Incorrect
Question 5 of 15
5. Question
What happens if the IN subquery contains NULLs?
Correct
Incorrect
Question 6 of 15
6. Question
Which one generally performs better on large datasets?
Correct
Incorrect
Question 7 of 15
7. Question
Choose the correct syntax for EXISTS:
Correct
Incorrect
Question 8 of 15
8. Question
Which query checks if a customer placed any orders?
Correct
Incorrect
Question 9 of 15
9. Question
When is IN more readable and better suited?
Correct
Incorrect
Question 10 of 15
10. Question
What does this return?
SELECT name FROM emp WHERE dept_id IN (SELECT id FROM dept WHERE location = ‘NY’);
Correct
Incorrect
Question 11 of 15
11. Question
Which one stops scanning as soon as a match is found?
Correct
Incorrect
Question 12 of 15
12. Question
Which is true about IN and EXISTS?
Correct
Incorrect
Question 13 of 15
13. Question
Which can be affected by NULL values in the subquery?
Correct
Incorrect
Question 14 of 15
14. Question
What does this query do?
SELECT * FROM products WHERE EXISTS (SELECT * FROM reviews WHERE reviews.product_id = products.id);
Correct
Incorrect
Question 15 of 15
15. Question
Which is preferred when dealing with subqueries involving multiple joins and large data?
Correct
Incorrect
Summary
Understanding the difference between SQL’s IN and EXISTS helps avoid performance issues and logic bugs—especially when dealing with NULLs and correlated subqueries.
At QuizOrbit, our team specializes in fun, informative quizzes across topics like general knowledge, technology, and entertainment. Boost your knowledge with our expert-designed quizzes.