Re: wired behaviour - Mailing list pgsql-sql

From Steve Crawford
Subject Re: wired behaviour
Date
Msg-id 49341C7A.5070000@pinpointresearch.com
Whole thread Raw
In response to Re: wired behaviour  (Shane Ambler <pgsql@Sheeky.Biz>)
List pgsql-sql
Shane Ambler wrote:
> Lutz Steinborn wrote:
>> Jepp, thats it.
>> I've supposed this but can't believe it. So NULL is something out of 
>> this
>> dimension :-)
>>
>>
>
> NULL refers to an unknown value - it cannot be said to equal or not 
> equal anything other than NULL ...
>
Not exactly. Null does not equal null. The "translation" being does 
some-unknown-value equal some-unknown-value? Answer: unknown.
If you want to determine if something is null you must use "is null".

select null = null;
null

select null is null;
true

If you want to treat nulls as a defined known value, use the coalesce 
function:
select coalesce(my_column, 'a null value')....;
will return the string 'a null value' whenever my_column is null.

Cheers,
Steve



pgsql-sql by date:

Previous
From: "John Dizaro"
Date:
Subject: how to update 400 000 register not at the same time?
Next
From: Alvaro Herrera
Date:
Subject: Re: [HACKERS] Reg: Nested query