Re: select * from users where user_id NOT in (select - Mailing list pgsql-general

From Alexander Farber
Subject Re: select * from users where user_id NOT in (select
Date
Msg-id 943abd910608180100l3db08f1cta0516abba1e75103@mail.gmail.com
Whole thread Raw
In response to Re: select * from users where user_id NOT in (select  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Responses Re: select * from users where user_id NOT in (select  (Roman Neuhauser <neuhauser@sigpipe.cz>)
List pgsql-general
Hello,

thank you and sorry for asking a FAQ.
I've fixed my problem now by:

select user_id, username from phpbb_users where user_id not in
(select ban_userid from phpbb_banlist where ban_userid is not null);

but still your explanation feels illogical
to me even though I know you're right...

On 8/18/06, Stephan Szabo <sszabo@megazone.bigpanda.com> wrote:
> When the subselect returns
> NULL for at least one row, you fall into this sort of case.
>
> x NOT IN (...) is equivalent to NOT(x IN (...)) which is
> NOT(x = ANY (...))
>
> x = ANY (...) is basically defined as
>  True if x = y is true for some y in the subselect
>  False if x = y is false for all y in the subselect
>  Unknown otherwise
>
> Since x = NULL is unknown and not true or false, you fall into the last
> case with your query and data.
>

Regards
Alex

--
http://preferans.de

pgsql-general by date:

Previous
From: "Sandeep Kumar Jakkaraju"
Date:
Subject: Re: Troubles linking with libpqxx
Next
From: Harald Fuchs
Date:
Subject: Re: Dynamic partial index