Re: weird results from trivial SELECT statement

From: "Oliveiros d'Azevedo Cristina" <oliveiros(dot)cristina(at)marktest(dot)pt>
To: "Lonni J Friedman" <netllama(at)gmail(dot)com>, <pgsql-novice(at)postgresql(dot)org>
Subject: Re: weird results from trivial SELECT statement
Date: 2011-04-27 16:47:09
Message-ID: 7A65A3A9461D4DF79077964EA5D0ADE0@marktestcr.marktest.pt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

From my knowledge, I think that NULL is not a value, it's rather the absense
of a value.
It doesn't matter if you use = or !=, testing 'disabled' against a NULL
column will always fail.

Why dont you try a WHERE clause like
WHERE active != 'disabled
OR active IS NULL
if you want the NULL records as well.

HTH,

Best,
Oliveiros

----- Original Message -----
From: "Lonni J Friedman" <netllama(at)gmail(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Sent: Wednesday, April 27, 2011 5:25 PM
Subject: [NOVICE] weird results from trivial SELECT statement

> 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!
>
> --
> Sent via pgsql-novice mailing list (pgsql-novice(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-novice

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Lonni J Friedman 2011-04-27 16:52:13 Re: weird results from trivial SELECT statement
Previous Message Lonni J Friedman 2011-04-27 16:25:36 weird results from trivial SELECT statement