David Wilson wrote:
On Thu, Oct 9, 2008 at 3:31 PM, Bill Thoen <[EMAIL PROTECTED]> 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;


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to