Search Postgresql Archives

Re: concatenating with NULLs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux