MINUS emulation? - Mailing list pgsql-sql

From Barry Baldwin
Subject MINUS emulation?
Date
Msg-id 319A9588FB5ED2119FAC00A0C912E3292785C0@INDYMEEXCH
Whole thread Raw
Responses Re: [SQL] MINUS emulation?  ("tjk@tksoft.com" <tjk@tksoft.com>)
Re: [SQL] MINUS emulation?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
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



pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: [SQL] Rule Question
Next
From: "tjk@tksoft.com"
Date:
Subject: Re: [SQL] MINUS emulation?