The EXISTS keyword in SQL is used to test for the existence of rows returned by a subquery. It’s often used in correlated subqueries for performance and conditional logic.
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.
SELECT name FROM students s WHERE EXISTS ( SELECT 1 FROM enrollments e WHERE e.student_id = s.id );
Correct
Incorrect
Question 4 of 15
4. Question
What is returned by the EXISTS subquery?
Correct
Incorrect
Question 5 of 15
5. Question
Can EXISTS be used without a correlated subquery?
Correct
Incorrect
Question 6 of 15
6. Question
What is the performance benefit of using EXISTS?
Correct
Incorrect
Question 7 of 15
7. Question
What value is commonly selected in an EXISTS subquery?
Correct
Incorrect
Question 8 of 15
8. Question
Which of the following is TRUE about EXISTS and IN?
Correct
Incorrect
Question 9 of 15
9. Question
Which of these is a valid EXISTS query?
SELECT name FROM customers c WHERE EXISTS ( SELECT 1 FROM orders o WHERE o.customer_id = c.id );
Correct
Incorrect
Question 10 of 15
10. Question
What does EXISTS return when subquery has no matching row?
Correct
Incorrect
Question 11 of 15
11. Question
What happens if EXISTS subquery returns multiple rows?
Correct
Incorrect
Question 12 of 15
12. Question
Which is more efficient on large tables with indexes?
Correct
Incorrect
Question 13 of 15
13. Question
Why is SELECT 1 used in EXISTS subqueries?
Correct
Incorrect
Question 14 of 15
14. Question
What is the output of this query?
SELECT department FROM departments d WHERE EXISTS ( SELECT 1 FROM employees e WHERE e.department_id = d.id AND e.salary > 50000 );
Correct
Incorrect
Question 15 of 15
15. Question
Can EXISTS be nested inside another EXISTS?
Correct
Incorrect
Summary
The `EXISTS` keyword is used in SQL subqueries to check if any row exists in the result of a subquery. It’s efficient, especially in correlated subqueries, and returns a boolean value, helping filter results based on conditional presence.
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.