Re: weird results from trivial SELECT statement - Mailing list pgsql-novice

From Brent Dombrowski
Subject Re: weird results from trivial SELECT statement
Date
Msg-id 19342B9D-1489-4E07-B207-9A40F5A2295A@gmail.com
Whole thread Raw
In response to weird results from trivial SELECT statement  (Lonni J Friedman <netllama@gmail.com>)
Responses Re: weird results from trivial SELECT statement
List pgsql-novice
On Apr 27, 2011, at 9:25 AM, Lonni J Friedman wrote:

> Greetings,
> I've got a Postgresql-8.4.x instance with a bunch of tables taht have
> a text column (called 'active') that can contain any one of the
> following values:
> NULL
> 'disabled'
> <some other text string>
>
> When I run the following query, it seems to ignore NULL values:
> SELECT * FROM mytbl WHERE active!='disabled'
>
> and only returns rows where active!='disabled' AND active IS NOT NULL.
> Is postgresql implicitly assuming that I want non-NULL values?
>
> I can provide additional information, if requested.
>
> thanks!

Unfortunately, there is only one NULL and it can take on several meanings. Because of this, most databases will not
performcomparison operations on NULL. NULL is not comparable to anything, including itself. NULL == NULL will return
FALSEon most systems. 

Some of the interpretations of NULL include, it is unknown if there should be data here, there is no data here, and
thereshould be data here but we don't know what it is. This generates enough controversy to merit a few PhD theses.
Yes,it is the database world it is possible to write a PhD thesis on nothing. 

Brent D.




pgsql-novice by date:

Previous
From: Lonni J Friedman
Date:
Subject: Re: weird results from trivial SELECT statement
Next
From: "John Payne"
Date:
Subject: failure and silence of SQL commands