Computing the aggreate value
Posted: Mon Jun 26, 2006 7:31 am
Hi all,
I am developing an ecommerce site on which category hireachy is infinitive.I mean, under one category many subcategories can be created and under that subcategory other subcategories can be created. From the admin side product can be added and it is can be assigned to any available category..
I have problem with computing the number of products which exists in one category.Since there are many child categories it should compute the number of products exists on that category too...
I would like to explain it as follows: category which has parent id 0 is the root category
So category hireachy will be
A>>Child A>>Child B>>Child C
B
Here product "PA" exists under "A" category, PB in "Child A",PC in "Child B" and PD in "Child C"
Now if we have to calculate the total products from Category A it should return 4, since other three categories are child category of this category....and each category holds the one product.
I tried to use join,but since category hireachy is not known i couldn't able to use that..
Thanx in advance
I am developing an ecommerce site on which category hireachy is infinitive.I mean, under one category many subcategories can be created and under that subcategory other subcategories can be created. From the admin side product can be added and it is can be assigned to any available category..
I have problem with computing the number of products which exists in one category.Since there are many child categories it should compute the number of products exists on that category too...
I would like to explain it as follows: category which has parent id 0 is the root category
Code: Select all
Category:
categoryid categoryname parentid
1 A 0
2 B 0
3 Child A 1
4 Child B 3
5 Child C 4A>>Child A>>Child B>>Child C
B
Code: Select all
Products
productid Product Name Categoryid
1 PA 1
2 PB 3
3 PC 4
4 PD 5Now if we have to calculate the total products from Category A it should return 4, since other three categories are child category of this category....and each category holds the one product.
I tried to use join,but since category hireachy is not known i couldn't able to use that..
Thanx in advance