Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

CountComments field in GDN_Category not accurate?

AoleeAolee Hobbyist & Coder ✭✭
edited December 2011 in Vanilla 2.0 - 2.8

hi anyone out there got an sql update script to update CountComments field in GDN_Category?

my problem is when you check this catergory page

http://pinoyau.info/categories/family-member-migration

you'll see 2 discussions and all in all 4 comments, but when you check

http://pinoyau.info/categories/all

the comment count for Family Member Migration is 0?

Best Answer

  • Options
    AoleeAolee Hobbyist & Coder ✭✭
    Answer ✓

    Found a fix,

    just incase anyone ran into the same problem...

    1. backup first your GDN_Category table, so you can revert anything bad happens.
    2. run this one shot SQL in your PHPmyadmin.


    create temporary table my_temp_table
    as
    SELECT iF(sum( b.CountComments ) is null,0,sum( b.CountComments )) as counter , a.CategoryID
    FROM gdn_category a
    LEFT JOIN GDN_Category b ON a.CategoryID = b.CategoryID
    GROUP BY CategoryID;

    UPDATE GDN_Category a, my_temp_table s SET a.CountComments = s.counter WHERE a.CategoryID = s.CategoryID;

Answers

  • Options
    AoleeAolee Hobbyist & Coder ✭✭
    Answer ✓

    Found a fix,

    just incase anyone ran into the same problem...

    1. backup first your GDN_Category table, so you can revert anything bad happens.
    2. run this one shot SQL in your PHPmyadmin.


    create temporary table my_temp_table
    as
    SELECT iF(sum( b.CountComments ) is null,0,sum( b.CountComments )) as counter , a.CategoryID
    FROM gdn_category a
    LEFT JOIN GDN_Category b ON a.CategoryID = b.CategoryID
    GROUP BY CategoryID;

    UPDATE GDN_Category a, my_temp_table s SET a.CountComments = s.counter WHERE a.CategoryID = s.CategoryID;

Sign In or Register to comment.