ExamVeda
Login
Home
This question belongs to MySQL MySQL Miscellaneous
MySQL Miscellaneous
?

Which operators test whether a subquery returns any rows?

Answer & Solution
Correct Answer: Option B
This question is about how we check if a smaller query (called a subquery) finds any matching data. Think of it like searching for a specific book in a library.

Option A: IN and NOT IN
These operators check if a value exists *within* a set of values returned by the subquery. They don't directly tell you if the subquery found *anything* at all.

Option B: EXISTS and NOT EXISTS
These are the key operators for checking if a subquery returns any rows!

Option C: PRESENT
This isn't a standard MySQL operator.

Option D: ABSENT
This also isn't a standard MySQL operator.

The Correct Answer is: Option B: EXISTS and NOT EXISTS

Why?
* EXISTS checks if the subquery returns at least one row. * NOT EXISTS checks if the subquery returns zero rows.

Example:
Let's say you have a table of students and another table of courses. You want to find students who are *not* enrolled in any courses. You could use NOT EXISTS to check if a student has any matching rows in the courses table.
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.