pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedfinding rows in one table not in another
4+ messages / 2 participants
[nested] [flat]
* finding rows in one table not in another
@ 1998-06-12 20:39 Brook Milligan <brook@trillium.NMSU.Edu>
0 siblings, 0 replies; 4+ messages in thread
From: Brook Milligan @ 1998-06-12 20:39 UTC (permalink / raw)
To: 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);
However, this revealed no rows, even though I know of instances where
id from mytable1 is absent from id in mytable2. Is there some other
way to do this? Am I missing something? Is there a workaround?
Cheers,
Brook
^ permalink raw reply [nested|flat] 4+ messages in thread
* RE: [SQL] finding rows in one table not in another
@ 1998-06-12 20:57 Jackson, DeJuan <djackson@cpsgroup.com>
0 siblings, 1 reply; 4+ messages in thread
From: Jackson, DeJuan @ 1998-06-12 20:57 UTC (permalink / raw)
To: Brook Milligan <brook@trillium.NMSU.Edu>; 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);
>
> However, this revealed no rows, even though I know of instances where
> id from mytable1 is absent from id in mytable2. Is there some other
> way to do this? Am I missing something? Is there a workaround?
>
> Cheers,
> Brook
>
try:
SELECT mytable1.id
FROM mytable1
WHERE NOT EXIST (SELECT mytable2.id
FROM mytable2
WHERE mytable1.id = mytable2.id);
-DEJ
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [SQL] finding rows in one table not in another
@ 1998-06-12 22:50 Brook Milligan <brook@trillium.NMSU.Edu>
parent: Jackson, DeJuan <djackson@cpsgroup.com>
0 siblings, 0 replies; 4+ messages in thread
From: Brook Milligan @ 1998-06-12 22:50 UTC (permalink / raw)
To: djackson@cpsgroup.com; +Cc: 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
^ permalink raw reply [nested|flat] 4+ messages in thread
* RE: [SQL] finding rows in one table not in another
@ 1998-06-12 22:54 Jackson, DeJuan <djackson@cpsgroup.com>
0 siblings, 0 replies; 4+ messages in thread
From: Jackson, DeJuan @ 1998-06-12 22:54 UTC (permalink / raw)
To: Brook Milligan <brook@trillium.NMSU.Edu>; +Cc: 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).
Yeah. Sorry for the typo.
> Cheers,
> Brook
-DEJ
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~1998-06-12 22:54 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1998-06-12 20:39 finding rows in one table not in another Brook Milligan <brook@trillium.NMSU.Edu>
1998-06-12 20:57 RE: [SQL] finding rows in one table not in another Jackson, DeJuan <djackson@cpsgroup.com>
1998-06-12 22:50 ` Brook Milligan <brook@trillium.NMSU.Edu>
1998-06-12 22:54 RE: [SQL] finding rows in one table not in another Jackson, DeJuan <djackson@cpsgroup.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox