Re: Question About UNION - Mailing list pgsql-general

From Bill Thoen
Subject Re: Question About UNION
Date
Msg-id 48EE6047.8070904@gisnet.com
Whole thread Raw
In response to Question About UNION  (Bill Thoen <bthoen@gisnet.com>)
List pgsql-general
David Wilson wrote:
> On Thu, Oct 9, 2008 at 3:31 PM, Bill Thoen <bthoen@gisnet.com> wrote:
>
>
>> Thanks, but that didn't work. That selected only the records from table1.
>>
>
> That's why I warned you about it being written in gmail. :)
>
I'm sorry, you had it right the first time. Here's a script that
verifies it:

create table table1 (
   a integer,
   b integer,
   c char(1)
);

insert into table1 values ( 1, 12, 'A');
insert into table1 values ( 2, 16, 'B');
insert into table1 values ( 8,  6, 'A');
insert into table1 values (19,  9, 'C');
insert into table1 values (20, 12, 'A');

create table table2 (
   a integer,
   b integer,
   c char(1)
);

insert into table2 values ( 1, 13, 'D');
insert into table2 values ( 2, 16, 'B');
insert into table2 values ( 8,  6, 'B');
insert into table2 values (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;

drop table table1;
drop table table2;


pgsql-general by date:

Previous
From: Bill Thoen
Date:
Subject: Re: Question About UNION
Next
From: Raymond O'Donnell
Date:
Subject: Fwd: Set-valued function in wrong context