Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== concatenating null strings ====== In Postgres, when using the || operator to concatenate fields into one string, if any of the fields contain a null value then the result will entirely be a null value. To avoid this problem, we can use the coalesce function: <code sql> select 'Doe' || ', ' || null || 'John' as name -- result will be null select coalesce('Doe','') || coalesce(', ','') || coalesce(null,'') || coalesce('John','') as name -- result will be 'Doe, John' </code> docs/postgres/concatenating_null_strings.txt Last modified: 2008/08/03 00:25by 127.0.0.1