QuestenaPractice that shows what to review next
Question 4

In PostgreSQL 18, what does SELECT NULL IN (SELECT 1 WHERE false); return, given that the subquery produces no rows?

  1. It raises an error
  2. true
  3. NULL
  4. falseCorrect answer

Explanation

IN over a subquery is false when no equal row is found, and that includes the case where the subquery returns nothing at all: with zero rows on the right, no comparison is ever performed, so nothing can be unknown. NULL is the tempting answer because a null left-hand side normally poisons the result, and it does as soon as the subquery returns a row: SELECT NULL IN (SELECT 1); returns NULL.

Continue with this test

Start practice
Question 4: In PostgreSQL 18, what does SELECT NULL IN (SELECT 1 WHERE… · SQL: NULL, Joins and Aggregates · Questena