From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | Janning Vygen <vygen(at)planwerk6(dot)de> |
Cc: | David Christian <davidc(at)comtechmobile(dot)com>, PostgreSQL-General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: showing also value '0' with aggregate count() |
Date: | 2001-09-29 18:13:08 |
Message-ID: | Pine.BSF.4.21.0109291103040.33581-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> Whats the difference?? when i ask for rows with "not id in" and my id
> is 3 and the subquery returns a NULL but no '3' than '3 is in NULL'
> ???
>
> Look at this:
>
> select 'funny' where not 3 in (NULL);
> ?column?
> ----------
> (0 rows)
>
> 3 is not in NULL!!
Actually, you don't know that. That's part of the three valued logic
and unknown NULL. Since NULL is an unknown value, you don't know
whether a 3 is equal to that NULL or not.
-- Stupid NULL related logic stuff --
The series goes like this
A NOT IN B is the same as
NOT (A IN B) is the same as
NOT (A =ANY B)
The result of A =ANY B is derived by the application of the
implied comparison predicate A = BT to every row in B [in this
case the NULL is effectively a one row values list].
If the = is true for at least one row BT in B, then
A=ANY B is true. If B is empty or if the = is false for
every row BT in B then A=ANY B is false. Otherwise A=ANY B
is unknown.
A=B is unknown if either A or B is the null value. Otherwise
A=B is true iff X and Y are equal. [simplified version of the
equality rules]
So, it does the 3=NULL comparison and gets an unknown back. There are
no other rows, so it was not true for at least one row, nor was it
false for all rows, so the =ANY is unknown. NOT (unknown) is unknown.
And the where clause returns those rows where the condition is true
so the row is not returned.
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2001-09-29 18:15:15 | Re: trigger compile problem |
Previous Message | peace_flower | 2001-09-29 16:19:01 | Elephant, Horse and Hare (Rabbit) : Oracle, PostgreSQL and MySQL ! |