Re: how does NOT work? - Mailing list pgsql-general

From Joel Burton
Subject Re: how does NOT work?
Date
Msg-id JGEPJNMCKODMDHGOBKDNMEANCLAA.joel@joelburton.com
Whole thread Raw
In response to Re: how does NOT work?  (tony <tony@animaproductions.com>)
List 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.


pgsql-general by date:

Previous
From: tony
Date:
Subject: Re: how does NOT work?
Next
From: "Joel Burton"
Date:
Subject: Re: how does NOT work?