Solved

MS Access Nested Joins

Posted on 2010-08-31
3
269 Views
Last Modified: 2012-06-27
From the query below, I need to join another table, ZipCode, that joins to the Ozips table where Left(ZipCode.zip,3) = Ozips.Ozip. Could someone assist?

SELECT Perishible.Mode
, Ozips.Orgn
, Ozips.Ozip
, Perishible.[Origin State Prov]
, Perishible.[Destination Zone Code]
, Warehouse.Nbr
, Warehouse.Location_City
, Warehouse.State
, Warehouse.[3Digit]
FROM Warehouse
INNER JOIN (Dzips
INNER JOIN (Ozips
RIGHT JOIN Perishible
ON Ozips.Orgn = Perishible.[Origin Zone Code])
ON Dzips.Drgn = Perishible.[Destination Zone Code])
ON Warehouse.[3Digit] = Dzips.[3Digit]
GROUP BY Perishible.Mode
, Ozips.Orgn
, Ozips.Ozip
, Perishible.[Origin State Prov]
, Perishible.[Destination Zone Code]
, Warehouse.Nbr
, Warehouse.Location_City
, Warehouse.State
, Warehouse.[3Digit]

0
Comment
Question by:dchau12
3 Comments
 
LVL 16

Accepted Solution

by:
carsRST earned 250 total points
ID: 33568225
SELECT Perishible.Mode
, Ozips.Orgn
, Ozips.Ozip
, Perishible.[Origin State Prov]
, Perishible.[Destination Zone Code]
, Warehouse.Nbr
, Warehouse.Location_City
, Warehouse.State
, Warehouse.[3Digit]
FROM Warehouse
INNER JOIN (Dzips
INNER JOIN (Ozips
RIGHT JOIN Perishible
ON Ozips.Orgn = Perishible.[Origin Zone Code])
ON Dzips.Drgn = Perishible.[Destination Zone Code])
ON Warehouse.[3Digit] = Dzips.[3Digit]

Inner join ZipCode z on
Left(z.zip,3) = Ozips.Ozip
GROUP BY Perishible.Mode
, Ozips.Orgn
, Ozips.Ozip
, Perishible.[Origin State Prov]
, Perishible.[Destination Zone Code]
, Warehouse.Nbr
, Warehouse.Location_City
, Warehouse.State
, Warehouse.[3Digit]
0
 

Author Comment

by:dchau12
ID: 33568682
Appreciate the quick response.

There's a missing operater here:

Warehouse.[3Digit] = Dzips.[3Digit]
Inner join ZipCode z on
Left(z.zip,3) = Ozips.Ozip

Should there be a set of parenthesis somewhere?

I tried moving the INNER JOIN on ZipCode to be nested in Ozips, but to no success.
0
 
LVL 77

Assisted Solution

by:peter57r
peter57r earned 250 total points
ID: 33569192
Why not do it in the Access query grid? You will get all the ( ) you need then.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In database programming, custom sort order seems to be necessary quite often, at least in my experience and time here at EE. Within the realm of custom sorting is the sorting of numbers and text independently (i.e., treating the numbers as number…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now