Create SQL String Dealing with Many to Many Relationship

Hello All,
Please see the picture for an overview of the small database I'm working with.  The following SQL string will get me the order ID, customer name, salesperson name, and shipping method for a specified salesperson and shipping method.

SELECT OrderInfo.ID, CustomerInfo.Name, SalesPerson.Name, ShipperInfo.Name
FROM ShipperInfo INNER JOIN (SalesPerson INNER JOIN (CustomerInfo INNER JOIN OrderInfo ON CustomerInfo.ID = OrderInfo.CustomerID) ON SalesPerson.ID = OrderInfo.SalesPersonID) ON ShipperInfo.ID = OrderInfo.ShipperID
WHERE SalesPerson.Name="Andrew Fuller" and = "United Package";

I need to be able to filter this data to only include orders which contained a specific product.  For example, along with the other WHERE criteria only include orders where one of the items ordered was Boston Crab Meat (i.e. ProductInfo.Name = "Boston Crab Meat")

Thanks a million

LVL 12
kgerbChief EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try This:

PARAMETERS SalesPerson Text ( 255 ), Shipper Text ( 255 ), Product Text ( 255 );
SELECT OrderInfo.ID, CustomerInfo.Name, SalesPerson.Name, ShipperInfo.Name, ProductInfo.Name, Orders.Quantity, Orders.ExtendedPrice
FROM ProductInfo INNER JOIN ((SalesPerson INNER JOIN (ShipperInfo INNER JOIN (CustomerInfo INNER JOIN OrderInfo ON CustomerInfo.ID = OrderInfo.CustomerID) ON ShipperInfo.ShipperID = OrderInfo.ShipperID) ON SalesPerson.SalesPersonID = OrderInfo.SalesPersonID) INNER JOIN Orders ON OrderInfo.ID = Orders.OrderID) ON ProductInfo.ProductID = Orders.ProductID
WHERE (((SalesPerson.Name)=[SalesPerson]) AND ((ShipperInfo.Name)=[Shipper]) AND ((ProductInfo.Name)=[Product]));

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kgerbChief EngineerAuthor Commented:
Thanks shambalad,
That will work nicely.  I've been starting at INNER JOINS for hours now.  I think my head is about to start spinning:).  Thanks again.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.