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

Home -> Community -> Usenet -> c.d.o.misc -> Re: LEFT OUTER JOIN problem with three linked tables

Re: LEFT OUTER JOIN problem with three linked tables

From: Richard Kuhler <noone_at_nowhere.com>
Date: Mon, 14 Apr 2003 19:24:34 GMT
Message-ID: <SVDma.38761$Hx.35739262@twister.socal.rr.com>


Martin wrote:
<snip>
> +------------+ +---------------+---------------+ +------------+
> | TABLE_1.ID | | TABLE_2.T1_ID | TABLE_2.T3_ID | | TABLE_3.ID |
> +------------+ +---------------+---------------+ +------------+
> | 1 | | 1 | 11 | | 11 |
> | 2 | | 2 | 12 | | 12 |
> | 3 | | 2 | 13 | | 13 |
> | 4 | +---------------+---------------+ +------------+
> +------------+
>
> I want to query the database so I get all ID's from TABLE_1 and their
> corresponding values from TABLE_3. If there are none, I should get
> NULL in that column, something like the following:
>
> +------------+------------+
> | TABLE_1.ID | TABLE_3.ID |
> +------------+------------+
> | 1 | 11 |
> | 2 | 12 |
> | 2 | 13 |
> | 3 | NULL |
> | 4 | NULL |
> +------------+------------+
 

select table_1.id, table_3.id
from table_1
left outer join table_2

    on table_2.t1_id = table_1.id
left outer join table_3

    on table_3.id = table_2.t3_id
/

Richard Received on Mon Apr 14 2003 - 14:24:34 CDT

Original text of this message

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