Solved

Access left join query

Posted on 2016-10-20
5
51 Views
Last Modified: 2016-10-20
Hello,

I have a query that was written in SQL.  I need to bring the query into Access and am having a lot of trouble with the left joins.  I'm getting a lot of errors saying missing expression, etc...  Could some one help me convert this to something Access understands?
---------------------------------
SELECT M.MIL_CODE

FROM
             QUOTE          Q

  INNER JOIN QUOTE_ITEM     QI  ON QI.QUOTE_ID        = Q.QUOTE_ID
                                    AND QI.QUOTE_VERS_STOP = Q.QUOTE_VERS

  INNER JOIN BOM_PIECE      BP  ON QI.QUOTE_ITEM_ID  = BP.QUOTE_ITEM_ID

  INNER JOIN EXTN           EX  ON BP.EXTN_LIB_ID    = EX.EXTN_LIB_ID
                                     AND BP.EXTN_ID        = EX.EXTN_ID

  INNER JOIN CLASSIFICATION CL  ON EX.CLASSIF_LIB_ID = CL.CLASSIF_LIB_ID
                               AND EX.CLASSIF_ID     = CL.CLASSIF_ID

  LEFT JOIN BOM_MIL         BM  ON BM.QUOTE_ITEM_ID  = BP.QUOTE_ITEM_ID
                                     AND BM.INSTANCE_IDENT = BP.INSTANCE_IDENT
                               AND BM.OBJ_ID         = BP.OBJ_ID

  LEFT JOIN MILLING         M   ON M.MIL_LIB_ID      = BM.MIL_LIB_ID
                                     AND M.MIL_ID          = BM.MIL_ID
---------------------------------

Thanks,
Joel
0
Comment
Question by:Genius123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 37

Expert Comment

by:PatHartman
ID: 41852727
Access uses an arcane syntax with lots of parentheses for joins.  The simplest solution if you are not familiar with it is to copy the select part of the query and then only copy the table names part of the FROM clause.  Then in QBE view, draw the joins and let Access generate the SQL for you.
0
 

Author Comment

by:Genius123
ID: 41852747
I tried that.  When I draw the left joins, I get this error.  I've tried making queries of queries and am just having a hard time with it....

left-join.pdf
0
 
LVL 37

Accepted Solution

by:
PatHartman earned 500 total points
ID: 41852760
The error message actually tells you how to solve the problem.

The way that joins work, you cannot have an inner join to the right of an outer join.

If you cannot rearrange the tables to conform to the rule, pluck out the two tables joined with a left join and put them in a separate query.  In the original query, replace the two tables with the new query.
0
 
LVL 20
ID: 41852879
you also have joins to dbo_BOM_MIL from 2 places. Perhaps a query with what you need from BOM_PIECE and BOM_MIL?

if relationships had referential integrity, the join line ends would be labeled with "1" or the infinity sign
0
 

Author Closing Comment

by:Genius123
ID: 41853103
thanks, that worked.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question