Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 099589FA4DF for ; Tue, 30 Jan 2007 01:45:55 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 71885-02 for ; Tue, 30 Jan 2007 01:45:48 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by postgresql.org (Postfix) with ESMTP id 18D259FA29C for ; Tue, 30 Jan 2007 01:45:48 -0400 (AST) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.8/8.13.8) with ESMTP id l0U5jiqx094507 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 29 Jan 2007 22:45:47 -0700 (MST) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.8/8.13.8) with ESMTP id l0U5jilw099623; Mon, 29 Jan 2007 22:45:44 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.8/8.13.8/Submit) id l0U5jhOa099622; Mon, 29 Jan 2007 22:45:43 -0700 (MST) (envelope-from mfuhr) Date: Mon, 29 Jan 2007 22:45:43 -0700 From: Michael Fuhr To: Phillip Smith Cc: pgsql-sql@postgresql.org Subject: Re: Differentiate Between Zero-Length String and NULL Column Values Message-ID: <20070130054543.GA98994@winnie.fuhr.org> References: <016d01c74430$043b1b90$9b0014ac@wbaus090> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <016d01c74430$043b1b90$9b0014ac@wbaus090> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/153 X-Sequence-Number: 27305 On Tue, Jan 30, 2007 at 04:32:22PM +1100, Phillip Smith wrote: > The second row (401600) is what I'm interested in for this particular > problem. The problem is when I try and add a WHERE clause: > SELECT * FROM tmpstk WHERE ean = ''; > SELECT * FROM tmpstk WHERE TRIM(ean) = ''; > SELECT * FROM tmpstk WHERE ean = NULL; > None of the above queries return any rows. Checking for equality against NULL won't work unless you have transform_null_equals set, which you shouldn't. Use IS NULL instead: SELECT * FROM tmpstk WHERE ean IS NULL; -- Michael Fuhr