Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 33B6C9FB317 for ; Tue, 30 Jan 2007 09:31:44 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 29515-03 for ; Tue, 30 Jan 2007 09:31:31 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id CF1F99FB2ED for ; Tue, 30 Jan 2007 09:31:31 -0400 (AST) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1HBtFz-0001h1-5E for pgsql-sql@postgresql.org; Tue, 30 Jan 2007 08:42:43 -0500 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 61A1241A5; Tue, 30 Jan 2007 08:13:34 -0500 (EST) Date: Tue, 30 Jan 2007 08:13:34 -0500 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: Differentiate Between Zero-Length String and NULL Column Values Message-ID: <20070130131334.GD31676@phlogiston.dyndns.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> User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/155 X-Sequence-Number: 27307 On Tue, Jan 30, 2007 at 04:32:22PM +1100, Phillip Smith wrote: > SHAMPOO","EQUEST","401600","0.00","0.00","0.00","0.00","10.00","" ^^ > SELECT * FROM tmpstk WHERE ean = NULL; ^^^^ Along with what Michael Fuhr said in his post about equality and NULL, Postgres doesn't treat the empty string and NULL as equivalent (because they're not). Only Oracle has that dodgy interpretation of SQL, as far as I know. If you want to use the empty string, you need WHERE ean = '' If you want instead ean to be NULL, use the traditional \N to signify NULL on your way in, or define null some other way. A -- Andrew Sullivan | ajs@crankycanuck.ca Users never remark, "Wow, this software may be buggy and hard to use, but at least there is a lot of code underneath." --Damien Katz