pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: tjk@tksoft.com <tjk@tksoft.com>
To: bbaldwin@indyme.com
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] MINUS emulation?
Date: Sun, 19 Dec 1999 18:18:25 -0800 (PST)
Message-ID: <199912200218.SAA26856@uno.tksoft.com> (raw)
In-Reply-To: <319A9588FB5ED2119FAC00A0C912E3292785C0@INDYMEEXCH>

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
> 
> 
> ************
> 
> 




view thread (3+ messages)  latest in thread

Message-ID: <199912200218.SAA26856@uno.tksoft.com>
Permalink:  ../199912200218.SAA26856@uno.tksoft.com/
Also on:    postgresql.org/message-id/199912200218.SAA26856@uno.tksoft.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tjk@tksoft.com, bbaldwin@indyme.com
  Subject: Re: [SQL] MINUS emulation?
  In-Reply-To: <199912200218.SAA26856@uno.tksoft.com>
  References: <319A9588FB5ED2119FAC00A0C912E3292785C0@INDYMEEXCH> <199912200218.SAA26856@uno.tksoft.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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