Re: Is this a feature ? - Mailing list pgsql-sql

From Joel Burton
Subject Re: Is this a feature ?
Date
Msg-id Pine.LNX.4.30.0206041325130.22841-100000@temp.joelburton.com
Whole thread Raw
In response to Is this a feature ?  (David BOURIAUD <david.bouriaud@ac-rouen.fr>)
List pgsql-sql
On Tue, 4 Jun 2002, David BOURIAUD wrote:

> Hi the list !
> I've read the docs, and found that you could concatenate two or more strings
> in one select statement like this :
> select
>     civ || name || forname as identity
> from
>     person;
>
> This just works fine and returns rows with only one column named identity.
> So far, if one of the fields (civ, name or forname) is null, identity is
> null... That doesn't seems right, since it means that 1+2+0 = 0 !!!!
> Has anybody else seen the same strange behaviour ? And is there a way to work
> this around ?

Yes, it's a feature, and yes, it's the standard.

No, it's not like 1+2+0=0. It's like 1+2+UNKNOWN=UNKNOWN, which is exactly
correct. NULL is __not__ the same thing as 0 or empty string; it
represents an unknown value.

Use the COALESCE function to turn a NULL value into something else.

- J.
-- 

Joel BURTON  |  joel@joelburton.com  |  joelburton.com  |  aim: wjoelburton
Independent Knowledge Management Consultant



pgsql-sql by date:

Previous
From: David BOURIAUD
Date:
Subject: Re: Is this a feature ?
Next
From: Matthew Price
Date:
Subject: Updating a table from another table