X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id B3FDC11F61F8 for ; Mon, 10 Apr 2006 19:04:36 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: 0.12 X-Spam-Level: X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id tKMvdjBgMrKh for ; Mon, 10 Apr 2006 19:04:25 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from rhino.esc1.com (dpc67142225134.direcpc.com [67.142.225.134]) by postgresql.org (Postfix) with ESMTP id 9A7CB11F602E for ; Mon, 10 Apr 2006 19:04:23 -0300 (ADT) Received: from rhino.esc1.com (localhost.localdomain [127.0.0.1]) by rhino.esc1.com (8.12.11/8.12.11) with ESMTP id k3AM3tRq015563 for ; Mon, 10 Apr 2006 18:03:58 -0400 Received: from localhost (localhost [[UNIX: localhost]]) by rhino.esc1.com (8.12.11/8.12.11/Submit) id k3AM3trY015561 for pgsql-sql@postgresql.org; Mon, 10 Apr 2006 18:03:55 -0400 From: Terry Lee Tucker Organization: Enhanced Solutions Computing 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 User-Agent: KMail/1.5.3 References: <20060410215556.GB5856@surnet.cl> In-Reply-To: <20060410215556.GB5856@surnet.cl> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200604101803.53355.terry@esc1.com> X-Archive-Number: 200604/68 X-Sequence-Number: 24877 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...