In Microsoft Access how do I build a query that tell me; The people who buy Prod
ID: 653354 • Letter: I
Question
In Microsoft Access how do I build a query that tell me; The people who buy Product A also purchase what other products? This is what I have so far.
SELECT Customers.ContactName, Products.ProductName
FROM Products INNER JOIN ((Customers INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID) INNER JOIN [Order Details] ON Orders.OrderID = [Order Details].OrderID) ON Products.ProductID = [Order Details].ProductID
GROUP BY Customers.ContactName, Products.ProductName
HAVING (((Products.ProductName)="Product A"))
ORDER BY Customers.ContactName;
Explanation / Answer
Your query is very complex ..you make more comparisions..I hope we can write it with less complexity.
SELECT Customers.ContactName,Products.ProductName From products INNER JOIN Customers,Products,Order GROUP BY Customers.ContactName, Products.ProductName
HAVING (((Products.ProductName)="Product A") AND Products.ProductID=Order.ProductID)
ORDER BY Customers.ContactName;
First of all getting all productID's with productname = product A...with that product Id we are fetching all orders having same product ID
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.