?
Solved

Access left join query

Posted on 2016-10-20
5
Medium Priority
?
71 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 39

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 39

Accepted Solution

by:
PatHartman earned 2000 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 22
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

649 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