Re: how does NOT work?

From: "Joel Burton" <joel(at)joelburton(dot)com>
To: "tony" <tony(at)animaproductions(dot)com>, "ARP" <arnaud(dot)mlist1(at)free(dot)fr>
Cc: "postgres list" <pgsql-general(at)postgresql(dot)org>
Subject: Re: how does NOT work?
Date: 2002-04-24 16:12:03
Message-ID: JGEPJNMCKODMDHGOBKDNMEANCLAA.joel@joelburton.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> Still don't understand the logic - I just want cells that don't start
> with "a" I don't care if they contain null values or not.
>
> But I will be rewriting everything so that there is a default value in
> each and every cell from now on.

The logic is this: in SQL, NULL is __NOT__ the same thing as 'empty'. It
means 'unknown'. And when you ask 'how many names start with A', you won't
get the names that are NULL (read: unknown). When you ask 'How many names DO
NOT start with A', you __still__ won't get the names that are NULL (read:
unknown), since, as they're unknown, it's impossible to say if they start
with A or not. It might seem pedantic, but very straightforward and
logically correct.

You can say either

WHERE column NOT LIKE 'a%' or column IS NULL

or

WHERE ( column LIKE 'a%' ) IS NOT TRUE;

The first is more clear to most people as it makes the NULL exception
explicit and obvious.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joel Burton 2002-04-24 16:13:06 Re: how does NOT work?
Previous Message tony 2002-04-24 16:06:13 Re: how does NOT work?