Re: Null in the where-clause - Mailing list pgsql-general

From Stephan Szabo
Subject Re: Null in the where-clause
Date
Msg-id 20020708100433.S27784-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Null in the where-clause  (michael_walzl@yahoo.de (Michael Walzl))
List 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.




pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: 7.2.1 optimises very badly against 7.2
Next
From: Andrew Sullivan
Date:
Subject: Re: Some Solaris notes, and an invitation