pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Terry Lee Tucker <terry@esc1.com>
To: pgsql-sql@postgresql.org
Subject: Re: concatenation with a null column (using ||) nulls the result?
Date: Mon, 10 Apr 2006 18:03:53 -0400
Message-ID: <200604101803.53355.terry@esc1.com> (raw)
In-Reply-To: <20060410215556.GB5856@surnet.cl>
References: <Pine.SOL.4.10.10604101430250.2779-100000@well.com>
	<20060410215556.GB5856@surnet.cl>

On Monday 10 April 2006 05:55 pm, Alvaro Herrera saith:
> Neil Harkins wrote:
> > Note: The cabinets_description for the "548-4th-Cab1" row is " ",
> > not NULL, hence it being displayed. Is this standard SQL behavior?
>
> Yes; something || NULL yields NULL.  If you want NULL to behave as ""
> for the purpose of the concatenation, try
>
> SELECT cabinets_name || ' - ' || COALESCE(cabinets_description, '') AS
> concat FROM cabinets WHERE cabinets_datacenters = 2;
>
> I'm assuming cabinets_name is NOT NULL, so it doesn't need COALESCE.
>
> --

Good to know. Thanks for the input...



view thread (5+ messages)  latest in thread

Message-ID: <200604101803.53355.terry@esc1.com>
Permalink:  ../200604101803.53355.terry@esc1.com/
Also on:    postgresql.org/message-id/200604101803.53355.terry@esc1.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: terry@esc1.com
  Subject: Re: concatenation with a null column (using ||) nulls the result?
  In-Reply-To: <200604101803.53355.terry@esc1.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox