Multiple choice technology databases

You define a multiple-row subquery in the WHERE clause of an SQL query with a comparison operator "=". What happens when the main query is executed?

  1. The main query executes with the first value returned by the subquery

  2. The main query executes with the last value returned by the subquery

  3. The main query executes with all the values returned by the subquery

  4. The main query fails because the multiple-row subquery cannot be used with the comparison operator

  5. You cannot define a multiple-row subquery in the WHERE clause of a SQL query

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Single-row operators like =, >, <, >=, <= can only be used with subqueries that return exactly ONE row. When a subquery returns multiple rows, you must use multiple-row operators like IN, ANY, ALL, or EXISTS. Using = with a multi-row subquery causes an error because the database cannot compare a single value to multiple values simultaneously. Option E is incorrect because you CAN define multiple-row subqueries in WHERE clauses, but you must use appropriate operators (IN, ANY, ALL, EXISTS) instead of =.

AI explanation

The "=" operator is a single-row comparison operator — it expects exactly one value on each side. If the subquery in the WHERE clause can return multiple rows, the database has no defined way to compare a single column value against several values using "=", so the query raises a runtime error (e.g., Oracle's "single-row subquery returns more than one row") rather than silently picking the first/last value or matching against all of them. To compare against multiple returned values you'd need IN, ANY, or ALL instead of "=". A multi-row subquery is legal syntactically in the WHERE clause — it's the operator choice that's incompatible, not the placement.