From: | "tjk(at)tksoft(dot)com" <tjk(at)tksoft(dot)com> |
---|---|
To: | bbaldwin(at)indyme(dot)com (Barry Baldwin) |
Cc: | pgsql-sql(at)postgreSQL(dot)org |
Subject: | Re: [SQL] MINUS emulation? |
Date: | 1999-12-20 02:18:25 |
Message-ID: | 199912200218.SAA26856@uno.tksoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Barry,
> I'm trying to do a query that returns all the records in one table unless
> they exist in another table.
This implies you need this:
Select A.field_id, A.data, B.field_id, B.data
from table_1 A, table_2 B where A.field_id not in
(select A.field_id from table_1 A, table_2 B where
A.field_id = B.field_id);
Troy
>
> Hi all,
>
> I'm trying to do a query that returns all the records in one table unless
> they exist in another table.
>
> For example the first query I tried was this;
>
> Select A.field_id, A.data, B.field_id, B.data
> from table_1 A, table_2 B
> where A.field_id <> B.field_id;
>
> This query resulted in no records being returned, I believe this is because
> Table_2 is empty.
>
> I then tried :
>
> Select field_id, data
> from table_1
> minus
> Select field_id, data
> from table_2;
>
> This didn't work because the Minus directive isn't recognized.
>
> Does anyone have a suggestion on how I might accomplish this?
>
> TIA,
>
> Barry
>
>
> ************
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 1999-12-20 03:10:48 | Re: [SQL] MINUS emulation? |
Previous Message | Barry Baldwin | 1999-12-20 01:47:06 | MINUS emulation? |