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

behavior of ' = NULL' vs. MySQL vs. Standards

From: Mark Stosberg <mark(at)summersault(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: behavior of ' = NULL' vs. MySQL vs. Standards
Date: 2001-06-07 01:00:45
Message-ID: 3B1ED23A.984C3159@summersault.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-sql
Hello,

I'm a long time Postgres user who uses MySQL when I have to. I recently
ran into an issue with MySQL where this construct didn't do what I expect:

WHERE date_column = NULL

I expected it to work like "date_column IS NULL" like it does it
Postgres 7.0.2, but instead it returned an empty result set. 

After conversing with some folks on the MySQL list, it was mentioned that:

 * "NULL is *NOT* a value. It's an absence of a value, and doing *any*
comparisons with NULL is invalid (the result must always be NULL, even
if you say "foo = NULL")." 

 * Postgres handling is non-standard (even if it's intuitive.) 

My questions then are: 1.) What IS the standard for handling NULLs? and
then 2.) If Postgres handling is different than the standard, what's the
reason? 

To me, having " = NULL" be the same as " IS NULL" is intuitive and thus
useful, but I also like appeal of using standards when possible. :) 

Thanks!

  -mark

http://mark.stosberg.com/

Responses

pgsql-hackers by date

Next:From: Tatsuo IshiiDate: 2001-06-07 01:03:15
Subject: Re: psql bug or feature?
Previous:From: Bruce MomjianDate: 2001-06-07 00:08:03
Subject: Re: Re: [HACKERS] Outstanding patches

pgsql-sql by date

Next:From: John ScottDate: 2001-06-07 01:08:14
Subject: Re: [SQL] maximum number of rows in table - what about oid limits?
Previous:From: Josh BerkusDate: 2001-06-06 23:12:06
Subject: Re: How to create a *pass-through-query* in postgresql

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