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

From Nick Fankhauser
Subject Re: Is this a feature ?
Date
Msg-id NEBBLAAHGLEEPCGOBHDGIEBLFBAA.nickf@ontko.com
Whole thread Raw
In response to Is this a feature ?  (David BOURIAUD <david.bouriaud@ac-rouen.fr>)
Responses Re: Is this a feature ?
List pgsql-sql
> 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 !!!!

The crux of the matter is that zero and null aren't the same thing. Null
means in essence "We don't know", so this equation is better writtin as:

1+2+"don't know" = "don't know"

> is there a
> way to work
> this around ?

It *is* often true that when concatenating strings, we want to tell SQL "if
this value is null, treat it like an empty string". This is how you would do
it:

coalesce( civ,'')||coalesce(name,'')||coalesce(forname,'')

Regards,

-Nick








pgsql-sql by date:

Previous
From: Jan Wieck
Date:
Subject: Re: Is this a feature ?
Next
From: David BOURIAUD
Date:
Subject: Re: Is this a feature ?