Re: concatenating with NULLs

From: Glen Parker <glenebob(at)nwlink(dot)com>
To: Seb <spluque(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: concatenating with NULLs
Date: 2011-04-25 22:28:54
Message-ID: 4DB5F5A6.6050107@nwlink.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 04/25/2011 02:13 PM, 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.

SELECT 'a' || 'b' || coalesce(NULL, '');

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Brent Wood 2011-04-25 22:32:59 Re: concatenating with NULLs
Previous Message Bosco Rama 2011-04-25 22:24:59 Re: concatenating with NULLs