Skip site navigation (1) Skip section navigation (2)

Re: comparing nulls

From: Reinoud van Leeuwen <reinoud(dot)v(at)n(dot)leeuwen(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: comparing nulls
Date: 2004-01-20 14:33:22
Message-ID: 20040120153322.U66382@spoetnik.xs4all.nl (view raw or flat)
Thread:
Lists: pgsql-sql
On Tue, Jan 20, 2004 at 07:13:12PM +0530, Kenneth Gonsalves wrote:
> in postgres7.1 i had a table where an integer field could be null. There was 
> no default value. a select statement like so:
> 'select * from table where field = null' 
> would give all the rows where that field had no value.
> on porting to 7.3.2, this doesnt work. How to do this?

Because NULL can be read as "unknown". It does not make much sense to 
test wheter a value of an integer is numerically equal to unknown. That is 
why there is the IS operator:

where field IS null

-- 
__________________________________________________
"Nothing is as subjective as reality"
Reinoud van Leeuwen    reinoud(dot)v(at)n(dot)leeuwen(dot)net
http://www.xs4all.nl/~reinoud
__________________________________________________

In response to

pgsql-sql by date

Next:From: Chris BowlbyDate: 2004-01-20 15:04:02
Subject: Re: comparing nulls
Previous:From: Luis SousaDate: 2004-01-20 14:30:57
Subject: Re: [SQL] Database diagram

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group