Re: How to retrieve rows with empty value in numeric(12,8) columns

From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: Adarsh Sharma <adarsh(dot)sharma(at)orkash(dot)com>
Cc: pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to retrieve rows with empty value in numeric(12,8) columns
Date: 2011-12-06 11:18:46
Message-ID: CAF-3MvNCNkKa=zXCJEPTuk5rTkZjWCmBdVywSdLTFiy1ouwUeg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 6 December 2011 12:00, Adarsh Sharma <adarsh(dot)sharma(at)orkash(dot)com> wrote:
>> select * from table where lat IS NULL;

> can you explain how it works or any link that explain the difference between
> 2 queries.

That's because of the 3-valued logic of SQL.
x=NULL always evaluates to NULL, because it is unknown whether the
two might be equal or not.
x IS NULL checks whether x is known (NOT NULL) or not (NULL) and
evaluates to TRUE or FALSE based on that.

WHERE-clauses only return rows where the expression evaluates to TRUE
and not rows where it evaluates to NULL or (obviously) FALSE.

--
If you can't see the forest for the trees,
Cut the trees and you'll see there is no forest.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bèrto ëd Sèra 2011-12-06 11:20:01 Re: How to retrieve rows with empty value in numeric(12,8) columns
Previous Message Raymond O'Donnell 2011-12-06 11:07:48 Re: How to retrieve rows with empty value in numeric(12,8) columns