Re: Combining text fields - Mailing list pgsql-novice

From Josh Berkus
Subject Re: Combining text fields
Date
Msg-id 200310171704.48986.josh@agliodbs.com
Whole thread Raw
In response to Combining text fields  (Doug Silver <dsilver@urchin.com>)
List pgsql-novice
Doug,

> I just want to confirm that this is the correct behavior for the return
value
> when combining text fields together.  If one of the fields is NULL, then the
> return value of field1+field2 also becomes NULL.  If this is correct, is the
> proper way to get around this to use a default value of '' for such fields?

Use "COALESCE", e.g.:

SELECT street1 || COALESCE(street2, '') || COALESCE(street3, '')

--
-Josh Berkus
 Aglio Database Solutions
 San Francisco


pgsql-novice by date:

Previous
From: Doug Silver
Date:
Subject: Combining text fields
Next
From: Daniel Staal
Date:
Subject: Re: scaleable design for multiple value tuple