Re: How do I check for NULL - Mailing list pgsql-general

From Thiemo Kellner
Subject Re: How do I check for NULL
Date
Msg-id bf0d7011-b973-4a76-bcc0-d43fbb39b2ff@gelassene-pferde.biz
Whole thread Raw
In response to Re: How do I check for NULL  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: How do I check for NULL
List pgsql-general
On 12/9/25 18:29, David G. Johnston wrote:
> On Tue, Dec 9, 2025 at 10:14 AM Thiemo Kellner 
> <thiemo@gelassene-pferde.biz> wrote:
>
>     I feel, you meant to say, the subquery does not return any record
>     which is not the same as returns NULL.
>
>
> For a scalar subquery the final output of a zero-row query is the null 
> value.
>
To me, it does not look like that (please note the empty line in the 
last example). Can you point me to the documentation saying that 0 rows 
is sometimes equal to 1 row?

postgres=# select * from pg_user;
  usename  | usesysid | usecreatedb | usesuper | userepl | usebypassrls 
|  passwd  | valuntil | useconfig
----------+----------+-------------+----------+---------+--------------+----------+----------+----------- 

  postgres |       10 | t           | t        | t       | t   | 
******** |          |
(1 row)

postgres=# select usename from pg_user where false;
  usename
---------
(0 rows)

postgres=# select null as usename from pg_user;
  usename
---------

(1 row)



pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: How do I check for NULL
Next
From: Justin Swanhart
Date:
Subject: Re: How do I check for NULL