K
Keith Ward
Hi,
I am trying to write a query to display categories that have products in
them by a specific supplier.
Tables:
Categories
Products
ProductsinCategories (because products can be in multiple categories)
Suppliers
The products table has an ID field to link to the supplier ID
Products in Categories has ProductID and CategoryID
Now when I do the following query it provides the correct information but I
just want the one category to show even if it appears more than once.
SELECT Categories.CategoryID, Categories.CategoryName,
Suppliers.SupplierPrefix
FROM Suppliers INNER JOIN (Products INNER JOIN (Categories INNER JOIN
ProductsInCategories ON Categories.CategoryID =
ProductsInCategories.CategoryID) ON Products.ProductID =
ProductsInCategories.ProductID) ON Suppliers.SupplierID =
Products.SupplierID
WHERE (((Suppliers.SupplierPrefix) Like "MA"));
Gives something like
1 Category1 SUP1
1 Category1 SUP1
2 Category2 SUP1
Telling me that supplier 1 has two products in category1 and one in
category2.
What I want is just for it to list what categories the supplier has products
in so I get
Category1
Category2
Basically just to remove the duplicates for display purposes.
Hope that's clear.
Regards
Keith
I am trying to write a query to display categories that have products in
them by a specific supplier.
Tables:
Categories
Products
ProductsinCategories (because products can be in multiple categories)
Suppliers
The products table has an ID field to link to the supplier ID
Products in Categories has ProductID and CategoryID
Now when I do the following query it provides the correct information but I
just want the one category to show even if it appears more than once.
SELECT Categories.CategoryID, Categories.CategoryName,
Suppliers.SupplierPrefix
FROM Suppliers INNER JOIN (Products INNER JOIN (Categories INNER JOIN
ProductsInCategories ON Categories.CategoryID =
ProductsInCategories.CategoryID) ON Products.ProductID =
ProductsInCategories.ProductID) ON Suppliers.SupplierID =
Products.SupplierID
WHERE (((Suppliers.SupplierPrefix) Like "MA"));
Gives something like
1 Category1 SUP1
1 Category1 SUP1
2 Category2 SUP1
Telling me that supplier 1 has two products in category1 and one in
category2.
What I want is just for it to list what categories the supplier has products
in so I get
Category1
Category2
Basically just to remove the duplicates for display purposes.
Hope that's clear.
Regards
Keith