Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

nested joins

Status
Not open for further replies.

mterveen

Technical User
May 16, 2000
18
US
need syntax help on the following join example (all left joins with the field names shown as links). the problem i run into is the link from tbl2 to tbl5 and the proper placement of the parens:

tbl1 (fld1)
|
+--->tbl2 (fld1,fld2)
|
+--->tbl3 (fld2,fld3)
| |
| +--->tbl4(fld3)
|
+--->tbl5 (fld2,fld5)
|
+--->tbl6 (fld5)

thanks for your time.
 
Try this:

Code:
SELECT  fields

  FROM    tbl1

    LEFT JOIN    tbl2
    ON    tbl1.fld1 = tbl2.fld1

      LEFT JOIN    tbl3
      ON    tbl2.fld2 = tbl3.fld2

        LEFT JOIN    tbl4
        ON    tbl3.fld3 = tbl4.fld3

      LEFT JOIN    tbl5
      ON    tbl2.fld2 = tbl5.fld2

        LEFT JOIN    tbl6
        ON    tbl5.fld5 = tbl6.fld5
 
thx john76 for the reply. that is what i ended up doing also and it worked. haven't double checked the results yet as to accuracy but it appears ok. concern i originally had was if there needed to be any parens used to correctly group the data.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top