Re: concatenation with a null column (using ||) nulls the result?
В списке pgsql-sql по дате отправления:
| От | Alvaro Herrera |
|---|---|
| Тема | Re: concatenation with a null column (using ||) nulls the result? |
| Дата | |
| Msg-id | 20060410215556.GB5856@surnet.cl обсуждение |
| Ответ на | concatenation with a null column (using ||) nulls the result? (Neil Harkins <nharkins@well.com>) |
| Ответы |
Re: concatenation with a null column (using ||) nulls the result?
|
| Список | pgsql-sql |
Neil Harkins wrote: > Note: The cabinets_description for the "548-4th-Cab1" row is " ", > not NULL, hence it being displayed. Is this standard SQL behavior? Yes; something || NULL yields NULL. If you want NULL to behave as "" for the purpose of the concatenation, try SELECT cabinets_name || ' - ' || COALESCE(cabinets_description, '') AS concat FROM cabinets WHERE cabinets_datacenters = 2; I'm assuming cabinets_name is NOT NULL, so it doesn't need COALESCE. -- Alvaro Herrera http://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support
В списке pgsql-sql по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера