Re: NOT IN queries - Mailing list pgsql-general

From Doug McNaught
Subject Re: NOT IN queries
Date
Msg-id m3g02f9z0j.fsf@varsoon.wireboard.com
Whole thread Raw
In response to NOT IN queries  (Nic Ferrier <nferrier@tapsellferrier.co.uk>)
List pgsql-general
Nic Ferrier <nferrier@tapsellferrier.co.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...

pgsql-general by date:

Previous
From: Nic Ferrier
Date:
Subject: NOT IN queries
Next
From: "Johnson, Shaunn"
Date:
Subject: PostgreSQL and explain