Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 8AA73476214 for ; Tue, 4 Jun 2002 13:26:42 -0400 (EDT) Received: from temp.joelburton.com (unknown [209.190.238.101]) by postgresql.org (Postfix) with ESMTP id A881B4761F2 for ; Tue, 4 Jun 2002 13:25:25 -0400 (EDT) Received: by temp.joelburton.com (Postfix, from userid 501) id 9D48C2BA2B; Tue, 4 Jun 2002 13:26:32 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by temp.joelburton.com (Postfix) with ESMTP id 9399B2B95F; Tue, 4 Jun 2002 13:26:32 -0400 (EDT) Date: Tue, 4 Jun 2002 13:26:32 -0400 (EDT) From: Joel Burton To: David BOURIAUD Cc: Subject: Re: Is this a feature ? In-Reply-To: <200206041018.24328.david.bouriaud@ac-rouen.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200206/29 X-Sequence-Number: 7994 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