Re: concatenating with NULLs - Mailing list pgsql-general

From Bosco Rama
Subject Re: concatenating with NULLs
Date
Msg-id 4DB5F4BB.3060304@boscorama.com
Whole thread Raw
In response to concatenating with NULLs  (Seb <spluque@gmail.com>)
List pgsql-general
Seb wrote:
> A query such as:
>
> SELECT 'a' || 'b' || NULL;
>
> returns a NULL.  How can I ensure I get 'ab' in the result?  I'm trying
> to concatenate columns and one of them might have NULL values, which I
> simply want to ignore.

COALESCE is your friend:
   select 'a' || 'b' || COALESCE(columnName, '');

HTH

Bosco.

pgsql-general by date:

Previous
From: Seb
Date:
Subject: concatenating with NULLs
Next
From: "Brent Wood"
Date:
Subject: Re: concatenating with NULLs