Re: outer join... please HELP!!!!

From: Furs Sergei <sef_at_bank.kemerovo.su>
Date: Sat, 16 Apr 94 14:27:44 +0700
Message-ID: <199404161431.AA00904_at_odb-gw.bank.kemerovo.su>


jmboivin_at_cti.ulaval.ca writes:
>Hi!,
>I have a problem with a complex outer join:
>I have 4 tables like that:
>table1
> key_table1
>table2
> key_table2
> key_table1 /* foreigh key on table 1 */
>table3
> key_table3
> key_table2 /* foreign key on table 2 */
>table4
> key_table4
> key_table3 /* foreign key on table 3 /*
>I want to build a SQL statement which will produce a list of ALL record
>in table 1 and, if there is a related record in table 4, will print the
>key value of table 4.
>Ex:
>key_table1 key_table4
>------------- ---------------
>1
>2 50 /* oups, their is a related record in table4 */
>3 25
>4
>5
>6 30
>and so...
>I tried with outer join but i don't understand how to use it when your join
>is on more than 2 tables.
>Please HELP!!!!
>

Hi! Try it:

SELECT table1.key_table1, table4.key_table4
>FROM table1, table2, table3 table4

WHERE table2.key_table1 (+) = table1.key_table1 AND
      table3.key_table2 (+) = table2.key_table2 AND
      table4.key_table3 (+) = table3.key_table3
ORDER BY table1.key_table1

It working.

Serge Furs. Received on Sat Apr 16 1994 - 09:27:44 CEST

Original text of this message