Re: Question regarding 'not in' and subselects - Mailing list pgsql-bugs

From Bruno Wolff III
Subject Re: Question regarding 'not in' and subselects
Date
Msg-id 20040526183824.GA3739@wolff.to
Whole thread Raw
In response to Question regarding 'not in' and subselects  (Vic Ricker <vicricker@charter.net>)
Responses Re: Question regarding 'not in' and subselects
List pgsql-bugs
On Wed, May 26, 2004 at 13:57:37 -0400,
  Vic Ricker <vicricker@charter.net> wrote:
> Hi.  I'm using PostgreSQL 7.4.2 under Fedora Core 1.
>
> I have two tables with a single varchar(32) column in each.  I'm trying
> to find all the rows from one table that don't exist in the other
> table.  The query that I am using is:
>
> select u.user_name from users u where u.user_name not in (select
> user_name from iasusers);
>
> (Actually, I'm doing something a bit more complex but this illustrates
> the problem.)
>
> It always seems to return 0 rows.  As a test, I inserted a row into
> users that I knew wasn't in iasuses but it didn't make a difference.
>
> If I remove the 'not', the query returns the rows that exist in both
> tables.
>
> If I replace the subselect with a list, it seems to work the way that
> I'd expect, i.e. "not in ('vic', 'joe')" it shows all the rows from
> users except for vic and joe.
>
> Am I doing something wrong or is this a bug?

Are there any nulls in iasusers.user_name?

pgsql-bugs by date:

Previous
From: Vic Ricker
Date:
Subject: Question regarding 'not in' and subselects
Next
From: Vic Ricker
Date:
Subject: Re: Question regarding 'not in' and subselects