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 76E0A11F66A0 for ; Mon, 10 Apr 2006 18:56:04 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: 1.474 X-Spam-Level: * X-Spam-Status: No, score=1.474 required=5 tests=[AWL=-0.445, DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44] Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 1AqrqiSHxRuM for ; Mon, 10 Apr 2006 18:55:56 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mx2.surnet.cl (mx2.surnet.cl [216.155.73.181]) by postgresql.org (Postfix) with ESMTP id BDF3D11F66EF for ; Mon, 10 Apr 2006 18:55:57 -0300 (ADT) Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) by mx2.surnet.cl with ESMTP; 10 Apr 2006 17:55:57 -0400 X-IronPort-AV: i="4.02,198,1139194800"; d="scan'208"; a="42151005:sNHT46371216" Received: from alvh.no-ip.org (201.221.200.14) by cluster.surnet.cl (7.0.043) (authenticated as alvherre@surnet.cl) id 43A978FD00E3416D; Mon, 10 Apr 2006 17:55:56 -0400 Received: by alvh.no-ip.org (Postfix, from userid 1000) id 48D7DC2DC22; Mon, 10 Apr 2006 17:55:56 -0400 (CLT) Date: Mon, 10 Apr 2006 17:55:56 -0400 From: Alvaro Herrera To: Neil Harkins Cc: pgsql-sql@postgresql.org Subject: Re: concatenation with a null column (using ||) nulls the result? Message-ID: <20060410215556.GB5856@surnet.cl> Mail-Followup-To: Neil Harkins , pgsql-sql@postgresql.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.11+cvs20060330 X-Archive-Number: 200604/67 X-Sequence-Number: 24876 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. -- Alvaro Herrera http://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support