Page 1 of 1

Extract categories for products

Posted: Fri Apr 04, 2014 7:49 am
by Tea-Dev
Hi.
I am trying to extract the categories for all the products identified in ac_Products. I can see the ac_Categories, but unable to join these 2 tables together.
Would anyone be able to provide a select statement where we can get the products and the categories they belong to (ac_products.productId, ac_Categories.Name, ....).

Re: Extract categories for products

Posted: Fri Apr 04, 2014 11:32 am
by mazhar
you need to look into ac_CatalogNode table. The SQL could be something like

Code: Select all

SELECT CN.CategoryId, P.Name
JOIN ac_CatalogNodes AS CN
JOIN ac_Products AS WP ON CN.CatalogNodeId = P.ProductId
WHERE CN.CatalogNodeTypeId = 1

Re: Extract categories for products

Posted: Thu May 15, 2014 7:54 am
by tripleW
This worked for me with a couple adjustments.

SELECT CN.CategoryId, P.Name
FROM ac_CatalogNodes AS CN
JOIN ac_Products AS P ON CN.CatalogNodeId = P.ProductId
WHERE CN.CatalogNodeTypeId = 1