Re: why the need for is null?

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Baldur Norddahl <bbn-pgsql(dot)general(at)clansoft(dot)dk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: why the need for is null?
Date: 2004-01-01 22:25:22
Message-ID: 20040101222522.GB7723@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Because in trivalued logic, <anything> = NULL is also NULL. You need a
special operator to check if something is NULL, hence IS NULL and IS NOT
NULL. SQL standard says so.

This is a FAQ but I don't see it mentioned there.

On Thu, Jan 01, 2004 at 10:45:35PM +0100, Baldur Norddahl wrote:
> Hi,
>
> How come "X=null" is not the same as "X is null"? I got a few selects with
> queries like this:
>
> select * from foo where customer=#customer# or (#customer# is null and customer
> is null)
>
> Without the last part, it will not correctly match null customers.
>
> PS. I am using the ibatis framework for java, so the #customer# gets translated
> to ? and the whole thing made into a prepared statement.
>
> Thanks,
>
> Baldur
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly

--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> (... have gone from d-i being barely usable even by its developers
> anywhere, to being about 20% done. Sweet. And the last 80% usually takes
> 20% of the time, too, right?) -- Anthony Towns, debian-devel-announce

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-01-01 22:27:10 Re: Mnogosearch (Was: Re: website doc search is ... )
Previous Message Martijn van Oosterhout 2004-01-01 22:21:12 Re: GetLastInsertID ?