Re: unexpected results with NOT IN query

From: "Mason Hale" <masonhale(at)gmail(dot)com>
To: "Stephan Szabo" <sszabo(at)megazone(dot)bigpanda(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: unexpected results with NOT IN query
Date: 2008-03-20 17:10:02
Message-ID: 8bca3aa10803201010pc2207as9a65bbb1adf967e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks -- that was it -- last_feed_download_task_id can indeed be null.

- Mason

On Thu, Mar 20, 2008 at 10:17 AM, Stephan Szabo <
sszabo(at)megazone(dot)bigpanda(dot)com> wrote:

> On Thu, 20 Mar 2008, Mason Hale wrote:
>
> > Hello --
> >
> > I'm getting some unexpected results with a NOT IN query -- this is on
> 8.2.5.
> >
> > This is the query in question:
> >
> > prod_2=> select id from feed_download_task where id in
> (111102466,141701504)
> > and id not in (select last_feed_download_task_id from subscription);
>
> Is it possible for last_feed_download_task_id be NULL? If so, then then id
> not in (...) will not ever return true due to the way comparisons with
> NULLs work -- basically, it can't tell if the id is in the other table
> because id = NULL is unknown, so it thus can't tell that it's not in the
> other table either, so you could end up with neither in nor not in
> returning the row.
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bjørn T Johansen 2008-03-20 17:12:58 Re: Which JDBC version to use with PostgreSQL 8.1.11?
Previous Message Zubkovsky, Sergey 2008-03-20 16:13:04 Re: Row size overhead