Re: concatenating with NULLs

Поиск
Список
Период
Сортировка
Искать
От
Bosco Rama
Тема
Re: concatenating with NULLs
Дата
Msg-id
4DB5F4BB.3060304@boscorama.com
Ответ на
Список
Дерево обсуждения
concatenating with NULLs Seb <spluque@gmail.com>
Re: concatenating with NULLs Bosco Rama <postgres@boscorama.com>
Re: concatenating with NULLs Glen Parker <glenebob@nwlink.com>
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 по дате отправления
От: Seb
Дата:
Сообщение: concatenating with NULLs
От: Brent Wood
Дата:
Сообщение: Re: concatenating with NULLs
FAQ