Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: weird type of outer join... matching only 1 row ??

Re: weird type of outer join... matching only 1 row ??

From: Christian Antognini <christian.antognini_at_trivadis.com>
Date: Mon, 19 Jul 2004 13:53:40 +0200
Message-ID: <40fbb61e@post.usenet.com>

Hi Rene

> create table table1 (
> key number (1),
> value1 number (4)
> );
>
> create table table2 (
> key number (1),
> field char (1),
> value2 number (4)
> );
>
> insert into table1 values (1, 1000);
> insert into table1 values (2, 1000);
>
> insert into table2 values (1, 'A', 200);
> insert into table2 values (1, 'B', 300);
> insert into table2 values (1, 'C', 50);
> insert into table2 values (3, 'A', 60);
>
> select distinct * from (
> select
> t1.key, t2.field, t1.value1, t2.value2
> from
> table1 t1 left join table2 t2 on t1.key = t2.key
> union
> select
> t1.key, t2.field, t1.value1, t2.value2
> from
> table1 t1 right join table2 t2 on t1.key = t2.key);
>
> drop table table1;
> drop table table2;

If I run your code I get the following output:

       KEY F VALUE1 VALUE2
---------- - ---------- ----------

         1 A       1000        200
         1 B       1000        300
         1 C       1000         50
         2         1000
           A                    60

i.e. this is not what Cip is looking for...

Chris

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Received on Mon Jul 19 2004 - 06:53:40 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US