Re: How to select rows with values set to NULL

From: "Joel Burton" <joel(at)joelburton(dot)com>
To: "Jani Averbach" <jaa(at)cc(dot)jyu(dot)fi>, "Tille, Andreas" <TilleA(at)rki(dot)de>
Cc: "PostgreSQL General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to select rows with values set to NULL
Date: 2002-05-23 12:36:57
Message-ID: JGEPJNMCKODMDHGOBKDNIECCCPAA.joel@joelburton.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org
> [mailto:pgsql-general-owner(at)postgresql(dot)org]On Behalf Of Jani Averbach
> Sent: Thursday, May 23, 2002 5:05 AM
> To: Tille, Andreas
> Cc: PostgreSQL General
> Subject: Re: [GENERAL] How to select rows with values set to NULL
>
>
> On Thu, 23 May 2002, Tille, Andreas wrote:
>
> jaa=# select * from test2 where txt = null;
> id | txt
> ----+-----
> 1 |
> (1 row)

> >
> > InfluenzaWeb=# select * from test where txt = NULL;
> > id | txt
> > ----+-----
> > (0 rows)

According to the strict rule of SQL, one instance of NULL does _not_ equal
another instance of NULL when considered in a where clause. So "where txt =
NULL" should never show you anything. To find a NULL value, use "where txt
IS NULL".

However, in the past, PG has allowed "where txt = NULL" (some other
databases do, too). In recent versions, PG only does this if you set the
option "transform_null_equals" in postgresql.conf or using SET. This option
is required by some stupid clients, such as Microsoft Access.

HTH.

Joel BURTON | joel(at)joelburton(dot)com | joelburton.com | aim: wjoelburton
Knowledge Management & Technology Consultant

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joel Burton 2002-05-23 12:39:13 Re: Substring from end of string
Previous Message Tina Messmann 2002-05-23 11:39:49 sequence / last_value problem