Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ANSI syntax for joining 4 tables-is this correct?

728558Oct 17 2009 — edited Oct 17 2009
Hi, I'm new to these forums and I've searched everywhere and can only find syntax and examples on how to join 2 and 3 tables using ANSI, but I need to join 4. For a traditional join it would be:

SELECT a.one, a.two, b.one, b.three, b.four, d.seven
FROM tablea a, tableb b, tablec c, tabled d
WHERE a.one = b.one
AND a.two = c.two
AND c.six = d.six;

Here are the tables:

tableb
one
three
four

tablea
one
two

tablec
two
six

tabled
six
seven
eight

Does anyone know how to do this using an ANSI join or have any resources that can point me in the right direction. I know if I wanted to join three tables it would be:

SELECT a.one, a.two, b.one, b.three, b.four, c.six
FROM tableb b JOIN tablea a ON b.one = a.one JOIN tablec c ON a.two = c.two;

so would joining a fourth be:

SELECT a.one, a.two, b.one, b.three, b.four, d.seven
FROM tableb b JOIN tablea a ON b.one = a.one JOIN tablec c ON a.two = c.two JOIN tabled d ON c.six = d.six; ???

Is the above correct or is there another way to do this using an ANSI Join?

Edited by: user1076466 on Oct 17, 2009 5:40 PM
This post has been answered by Himanshu Kandpal on Oct 17 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 14 2009
Added on Oct 17 2009
3 comments
597 views