Re: Question About UNION

From: "David Wilson" <david(dot)t(dot)wilson(at)gmail(dot)com>
To: "Bill Thoen" <bthoen(at)gisnet(dot)com>
Cc: rod(at)iol(dot)ie, pgsql-general(at)postgresql(dot)org
Subject: Re: Question About UNION
Date: 2008-10-09 17:54:44
Message-ID: e7f9235d0810091054g5f865d54l4943d4c2a0d4fb5a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Oct 9, 2008 at 1:48 PM, Bill Thoen <bthoen(at)gisnet(dot)com> wrote:
> No, this won't work. Here's an example of my tables:
> Table1
> 1, 12, A
> 2, 16, B
> 8, 6, A
> 19, 9, C
>
> Table2
> 1, 13, D
> 2, 16, B
> 8, 6, B
> 12, 5, A

select * from table1
union
select table2.* from table2 left join table1 on table2.a=table1.a and
table2.b=table1.b where table2.a is null;

(Written in gmail, but you should get the basic idea.)

--
- David T. Wilson
david(dot)t(dot)wilson(at)gmail(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joao Ferreira gmail 2008-10-09 18:42:41 when COPY violates Primary Keys
Previous Message Bill Thoen 2008-10-09 17:48:26 Re: Question About UNION