Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice

> I just want to confirm that this is the correct behavior for the return 
> 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

pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group