Re: Null in the where-clause

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Michael Walzl <michael_walzl(at)yahoo(dot)de>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Null in the where-clause
Date: 2002-07-08 17:07:11
Message-ID: 20020708100433.S27784-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On 5 Jul 2002, Michael Walzl wrote:

> Hello everybody,
>
> I've got a problem with the "null"-statement within the where-clause.
> I installed the postgres-server 7.2.1 on a Suse Linux machine.
> Then I imported an existing databasedump.
> But when I make the following query:
> select * from tbl_categories where categoryid=null;
> I get 0 rows as result, but there are several records, which
> corrsponds to my query.

I doubt that ;) categoryid=null never returns true, even when
categoryid is null itself (as per SQL spec). You really want the
query:
select * from tbl_categories where categoryid IS null;

or, set TRANSFORM_NULL_EQUALS which turns =null into IS null,
but that's not recommended unless you can't change the queries
since that might break if someone expects =null to work properly.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Robert L Mathews 2002-07-08 17:16:05 Re: I am being interviewed by OReilly
Previous Message Stephan Szabo 2002-07-08 17:04:25 Re: Bug in 7.2.1? -- ERROR: Adding columns with defaults