tags:

views:

51

answers:

2

If inner subquery returns zero rows then what will be the answer? No rows return, outer query result will be shown, error…

A: 

It depends on what you are using the subquery for. If it's to display data, the result of the subquery will be null. If you are using it for an inner join, then the join operation will return no rows.

Gerrie Schenck
+1  A: 

In scalar context the subquery will return:

  • NULL if 0 rows returned
  • The value returned if 1 row returned
  • An error if 2 or more rows returned.
Quassnoi