Re: Differentiate Between Zero-Length String and NULL Column Values - Mailing list pgsql-sql

From Michael Fuhr
Subject Re: Differentiate Between Zero-Length String and NULL Column Values
Date
Msg-id 20070130054543.GA98994@winnie.fuhr.org
Whole thread Raw
In response to Differentiate Between Zero-Length String and NULL Column Values  ("Phillip Smith" <phillip.smith@weatherbeeta.com.au>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: "Phillip Smith"
Date:
Subject: Differentiate Between Zero-Length String and NULL Column Values
Next
From: Niklas Bergius
Date:
Subject: Arrays, multidimensional ANY (v 8.2)