Re: what is the best way to concat fields that may contain null as if they were empty strings

From: Andreas Kretschmer <akretschmer(at)spamfence(dot)net>
To: pgsql-general(at)postgresql(dot)org
Cc: Reid Thompson <reid(dot)thompson(at)ateb(dot)com>
Subject: Re: what is the best way to concat fields that may contain null as if they were empty strings
Date: 2009-10-09 16:18:02
Message-ID: 20091009161802.GA11724@tux
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Reid Thompson <reid(dot)thompson(at)ateb(dot)com> wrote:

> In the case where a_text is null, I essentially want the same result as the case when a_text = ''.
>
> would this:
> select a_int || coalesce(a_text,'') from test1 where a_int = 1000002;
> be the proper way?

Yes.

Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknown)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Raymond O'Donnell 2009-10-09 16:29:27 Re: array question
Previous Message Whit Armstrong 2009-10-09 16:17:39 array question