pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joel Burton <joel@joelburton.com>
To: David BOURIAUD <david.bouriaud@ac-rouen.fr>
Cc: pgsql-sql@postgresql.org
Subject: Re: Is this a feature ?
Date: Tue, 4 Jun 2002 13:26:32 -0400 (EDT)
Message-ID: <Pine.LNX.4.30.0206041325130.22841-100000@temp.joelburton.com> (raw)
In-Reply-To: <200206041018.24328.david.bouriaud@ac-rouen.fr>

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




view thread (7+ messages)

Message-ID: <Pine.LNX.4.30.0206041325130.22841-100000@temp.joelburton.com>
Permalink:  ../Pine.LNX.4.30.0206041325130.22841-100000@temp.joelburton.com/
Also on:    postgresql.org/message-id/Pine.LNX.4.30.0206041325130.22841-100000@temp.joelburton.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: joel@joelburton.com, david.bouriaud@ac-rouen.fr
  Subject: Re: Is this a feature ?
  In-Reply-To: <Pine.LNX.4.30.0206041325130.22841-100000@temp.joelburton.com>
  References: <200206041018.24328.david.bouriaud@ac-rouen.fr> <Pine.LNX.4.30.0206041325130.22841-100000@temp.joelburton.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox