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, '');
--
S
Sent: Monday, April 25, 2011 6:33 PM
To: splu...@gmail.com; pgsql-general@postgresql.org
Subject: Re: [GENERAL] concatenating with NULLs
Hi Seb,
Use CASE to change nulls to empty strings (or a placeholder) as below.
See: http://www.postgresql.org/docs/9.0/static/functions-conditional.html
if
Hi,
Thanks for all the helpful suggestions everyone!
Cheers,
Seb
On Tue, 26 Apr 2011 10:32:59 +1200,
"Brent Wood" wrote:
> Hi Seb, Use CASE to change nulls to empty strings (or a placeholder)
> as below.
> See:
> http://www.postgresql.org/docs/9.0/static/functions-conditional.html
> if you
Hi Seb,
Use CASE to change nulls to empty strings (or a placeholder) as below.
See: http://www.postgresql.org/docs/9.0/static/functions-conditional.html
if you want a placeholder in the result to indicate the presence of a null, try
the second SQL:
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(col