From: | Bill Thoen <bthoen(at)gisnet(dot)com> |
---|---|
To: | David Wilson <david(dot)t(dot)wilson(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Question About UNION |
Date: | 2008-10-09 19:49:27 |
Message-ID: | 48EE6047.8070904@gisnet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
David Wilson wrote:
> On Thu, Oct 9, 2008 at 3:31 PM, Bill Thoen <bthoen(at)gisnet(dot)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;
From | Date | Subject | |
---|---|---|---|
Next Message | Raymond O'Donnell | 2008-10-09 19:52:17 | Fwd: Set-valued function in wrong context |
Previous Message | David Wilson | 2008-10-09 19:35:32 | Re: Question About UNION |