Re: calculating total products in each category
Posted by:
tep .
Date: January 04, 2010 08:13AM
I finalized the situation and divided small part instead of big whole part :-)
Here is the solution that anyone who needs face with same problem !
1. truncate table tmp_category_total
2. insert into tmp_category_total
(category,total)
select category,count(*)
from product
where active = ?active
group by category
3. update category set total = 0
4. UPDATE category c,(SELECT parent.ctgid, sum(summary_product.total) adet
FROM category AS node,
category AS parent,
tmp_category_total summary_product
WHERE node.lft BETWEEN parent.lft AND parent.rgt
AND node.ctgid = summary_product.category
GROUP BY parent.ctgid
ORDER BY node.lft) a
SET c.total = a.adet
WHERE c.ctgid = a.ctgid
Total duration about 1 second !
Thanks anyone who helped me especially to Rick James :)
tep
Edited 1 time(s). Last edit at 01/04/2010 08:14AM by tep ..
Subject
Views
Written By
Posted
4528
December 16, 2009 04:26AM
1980
December 17, 2009 09:58AM
2131
December 18, 2009 07:46AM
2216
December 18, 2009 07:50AM
1979
December 23, 2009 08:15AM
1973
December 29, 2009 09:54PM
2219
December 30, 2009 02:35AM
2069
December 30, 2009 08:09PM
2414
December 31, 2009 12:39AM
4950
December 31, 2009 01:42AM
Re: calculating total products in each category
3329
January 04, 2010 08:13AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.