Re: NOT IN queries

From: Doug McNaught <doug(at)wireboard(dot)com>
To: Nic Ferrier <nferrier(at)tapsellferrier(dot)co(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: NOT IN queries
Date: 2002-04-01 16:14:52
Message-ID: m3g02f9z0j.fsf@varsoon.wireboard.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-announce pgsql-general pgsql-hackers

Nic Ferrier <nferrier(at)tapsellferrier(dot)co(dot)uk> writes:

> create table t1 (id integer, name varchar(20), t2_id integer);
> insert into t1 (id, name, t2_id) values (1, 'nic', 2);
> insert into t1 (id, name, t2_id) values (2, 'jim', NULL);
>
> create table t2 (id integer, name varchar(20));
> insert into t1 (id, name, t2_id) values (1, 'ferrier');
> insert into t1 (id, name, t2_id) values (2, 'broadbent');
>
> And now do this query:
>
> select * from t2 where id not in (select t2_id from t1);
>
> then I get a NULL response (ie: no rows returned).

Well, you never inserted any rows into t2, so that makes sense.

-Doug
--
Doug McNaught Wireboard Industries http://www.wireboard.com/

Custom software development, systems and network consulting.
Java PostgreSQL Enhydra Python Zope Perl Apache Linux BSD...

In response to

Browse pgsql-announce by date

  From Date Subject
Next Message Tom Lane 2002-04-01 16:21:54 Re: NOT IN queries
Previous Message Nic Ferrier 2002-04-01 15:55:32 NOT IN queries

Browse pgsql-general by date

  From Date Subject
Next Message Johnson, Shaunn 2002-04-01 16:21:03 PostgreSQL and explain
Previous Message Nic Ferrier 2002-04-01 15:55:32 NOT IN queries

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2002-04-01 16:21:54 Re: NOT IN queries
Previous Message Jan Wieck 2002-04-01 16:14:10 Re: Data integrity and sanity check