Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: LEFT OUTER JOIN problem with three linked tables
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
![]() |
![]() |