Re: Combining text fields

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Doug Silver <dsilver(at)urchin(dot)com>, pgsql-novice(at)postgresql(dot)org
Subject: Re: Combining text fields
Date: 2003-10-18 00:04:48
Message-ID: 200310171704.48986.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Daniel Staal 2003-10-18 01:38:21 Re: scaleable design for multiple value tuple
Previous Message Doug Silver 2003-10-17 23:46:41 Combining text fields