Re: [SQL] finding rows in one table not in another

From: Brook Milligan <brook(at)trillium(dot)NMSU(dot)Edu>
To: djackson(at)cpsgroup(dot)com
Cc: pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] finding rows in one table not in another
Date: 1998-06-12 22:50:14
Message-ID: 199806122250.QAA00571@trillium.nmsu.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> I need to find the set of rows in one table that are not in another
> table. I used a query like the following:
>
> select distinct id from mytable1 where id not in (select
> distinct id from mytable2);
>
try:
SELECT mytable1.id
FROM mytable1
WHERE NOT EXIST (SELECT mytable2.id
FROM mytable2
WHERE mytable1.id = mytable2.id);

Thanks. That works except it should be EXISTS (i.e., plural).

Cheers,
Brook

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jackson, DeJuan 1998-06-12 22:54:57 RE: [SQL] finding rows in one table not in another
Previous Message Tim J Trowbridge 1998-06-12 21:21:27 Re: [SQL] DefineQueryRewrite: rule plan string too big