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