Results 1 to 10 of 10
  1. #1
    juniormint is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    6

    Help! I'm having trouble with multiple table joins


    Hello -

    I have to join 13 tables; 3 are left joins, one is right and all others are inner. I tried to do this in the query designer because Access doesn't like my joins from a Sql Server query. Even though Access creates the joins itself, it still gives an error - Join Not Supported.

    This is exasperating! If it doesn't know what it wants, how should I know? I don't know what else to try.

    Does anyone have an example of a multiple table query with multiple join types?

    Any help will be greatly appreciated. Thanks.

  2. #2
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,085
    can you post the SQL from your Query here? it'll be easier to help

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,598
    I have some with INNER and RIGHT, INNER and INNER, LEFT and RIGHT, RIGHT and RIGHT. Didn't find any INNER and LEFT but I do have at least one with all three.
    SELECT Submit.LabNum
    FROM ConstructionSampleInfo INNER JOIN (0SoilsAggPrep RIGHT JOIN
    (SUBMIT LEFT JOIN 105 ON SUBMIT.LabNum = [105].LabNum)
    ON [0SoilsAggPrep].LabNum = SUBMIT.LabNum)
    ON ConstructionSampleInfo.LabNum = SUBMIT.LabNum
    WHERE (((Submit.MaterialType) = "Soils & Aggregate"))
    ORDER BY Submit.LabNum;

    Might have to do some intermediate queries.

    If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    juniormint is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    6

    Here's some pseudo code. I am unable to post actual code due to confidentiality issu

    Quote Originally Posted by RayMilhon View Post
    can you post the SQL from your Query here? it'll be easier to help
    Thanks for your response. Below is pseudo code. I can't post the actual code. Any help is appreciated!

    SELECT Linked_tbl1.col5, Linked_tbl2.col4, Linked_tbl3.col3, Linked_tbl3.col4, Linked_tbl3.col5, Linked_tbl3.col6,
    Linked_tbl4.col2, Linked_tbl5.col8, Linked_tbl5.col9, Linked_tbl6.col2, Linked_tbl7.col3, Linked_tbl3.col8, Linked_tbl3.col9,
    Linked_tbl7.col10, Linked_tbl8.col5, Linked_tbl8.col6, Linked_tbl9, Linked_tbl3.col3, CurrDB_tbl10.col4, Linked_tbl11.col7,
    CurrDB_tbl11.col6, CurrDB_tbl11.col8, Linked_tbl6.col8, CurrDB_tbl11.col2, CurrDB_tbl10
    RIGHT JOIN ((Linked_tbl11
    LEFT JOIN ((((Linked_tbl8
    LEFT JOIN ((Linked_tbl5
    INNER JOIN (Linked_tbl2
    LEFT JOIN ((Linked_tbl3
    INNER JOIN Linked_tbl6 ON
    Linked_tbl3.Key = Linked_tbl6.Key)
    INNER JOIN Linked_tbl4 RMTRX ON
    Linked_tbl6.Indexkey=Linked_tbl4.Indexkey) ON
    Linked_tbl2.Key=Linked_tbl3.Key) ON
    Linked_tbl5.Key=Linked_tbl3.Key)
    INNER JOIN Linked_tb19 ON
    Linked_tbl3.Key=Linked_tbl9.Key) ON
    Linked_tbl8.Key=Linked_tbl3.Key)
    INNER JOIN Linked_tbl7 ON
    Linked_tbl3.Key=Linked_tbl7.Key)
    INNER JOIN Linked_tbl1 ON
    Linked_tbl3.Key=Linked_tbl1.Key)
    INNER JOIN Linked_tbl7 ON
    Lined_tbl3.Key=Linked_tbl7.Key) ON
    Linked_tbl11=Linked_tbl3)
    LEFT JOIN CurrDB_tbl11 ON
    Linked_tbl6.CommonCol= CurrDB_tbl11.CommnCol) ON
    CSTR(CurrDB_tbl10.NumericCol)=Linked_tbl3.TextCol
    WHERE (((Linked_tbl3.Date) Between #1/2/2010# And #7/1/2012#) AND
    ((Linked_tbl4.Col5)=1));

  5. #5
    juniormint is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    6

    Is there a specific order for left, right and inner joins?

    Thanks for responding. Do you know if there a specific order the three different joins are supposed to have? Please see my pseudo-code above. I can't upload the database due to confidentiality issues. By the way, the pseudo-code above was produced by Access and Access does not like its own code.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,598
    You have relationships set up? Access query designer will generate the join syntax based on established relationships. You can change the jointype in query if necessary. I suspect all the INNER joins are causing issue. I would have to test query with tables. Don't need real data, just dummy records. If you can't provide, can't help.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Apart from June's suggestion,
    Is there a copy-paste error in the SQL you have posted or am I missing something?

    Code:
     
    SELECT 
    	Linked_tbl1.col5, Linked_tbl2.col4, 	Linked_tbl3.col3, Linked_tbl3.col4, 	Linked_tbl3.col5, 	Linked_tbl3.col6,	Linked_tbl4.col2, 	Linked_tbl5.col8, 	Linked_tbl5.col9, 
    	Linked_tbl6.col2, 	Linked_tbl7.col3, 	Linked_tbl3.col8, 	Linked_tbl3.col9,	Linked_tbl7.col10, 	Linked_tbl8.col5, 	Linked_tbl8.col6, 
    	Linked_tbl9, 
    	Linked_tbl3.col3, 	CurrDB_tbl10.col4, 	Linked_tbl11.col7,	CurrDB_tbl11.col6, 	CurrDB_tbl11.col8, 	Linked_tbl6.col8, 	CurrDB_tbl11.col2, 
    	CurrDB_tbl10
     RIGHT JOIN
    .....
    Also is there a FROM ... missing ?

    Thanks

  8. #8
    juniormint is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    6
    Quote Originally Posted by recyan View Post
    Apart from June's suggestion,
    Is there a copy-paste error in the SQL you have posted or am I missing something?

    Code:
     
    SELECT 
        Linked_tbl1.col5, Linked_tbl2.col4,     Linked_tbl3.col3, Linked_tbl3.col4,     Linked_tbl3.col5,     Linked_tbl3.col6,    Linked_tbl4.col2,     Linked_tbl5.col8,     Linked_tbl5.col9, 
        Linked_tbl6.col2,     Linked_tbl7.col3,     Linked_tbl3.col8,     Linked_tbl3.col9,    Linked_tbl7.col10,     Linked_tbl8.col5,     Linked_tbl8.col6, 
        Linked_tbl9, 
        Linked_tbl3.col3,     CurrDB_tbl10.col4,     Linked_tbl11.col7,    CurrDB_tbl11.col6,     CurrDB_tbl11.col8,     Linked_tbl6.col8,     CurrDB_tbl11.col2, 
        CurrDB_tbl10
    RIGHT JOIN
    .....
    Also is there a FROM ... missing ?

    Thanks
    Yeah -- I did forget to copy the From, although it is in the original. I figured out my problem. If you notice in my code, I was trying to edit the Access code; in other words, write it like Access would. I finally started from scratch and simply used for example, FROM tbl3 and put each join in like I would in sql server, but each time I did, I put a parentheses at the end of that particular join and I when back to the tbl3 part and added a parenthesis there until, of course, the last join, which simply has a semicolon. Thanks for everyone who responded!

  9. #9
    juniormint is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    6
    Since this was an existing DB, I had thought the relationships were already set up. Turned out they weren't. I found that out after I had written all the code out by hand, though . . . sigh

    Thanks for the help!

  10. #10
    juniormint is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    6
    Where do I mark the June7 solution as the answer? I'm not seeing a button . . .

Please reply to this thread with any new information or opinions.

Similar Threads

  1. sql problems with multiple inner joins
    By mejia.j88 in forum Queries
    Replies: 1
    Last Post: 01-03-2012, 05:41 PM
  2. Multiple Left Joins From Same Column
    By x0200196 in forum Access
    Replies: 1
    Last Post: 09-08-2011, 10:14 AM
  3. Multiple Joins in multiple tables
    By access_user123 in forum Access
    Replies: 1
    Last Post: 06-22-2011, 02:51 AM
  4. Multiple joins, avoiding cross joined result
    By richjhart in forum Queries
    Replies: 2
    Last Post: 09-17-2010, 09:32 AM
  5. Multiple outer joins - error message
    By Lipi in forum Queries
    Replies: 1
    Last Post: 09-16-2010, 02:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums