In a D7 site, comments are voted using rate module.
I'm wondering how to get the rating of all comments of 'story' content using raw sql query?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityHere you are SQL to get the total vote count for widget type number for each comment od node type "story"
SELECT c.cid,count(v.vote_id) FROM votingapi_vote v JOIN comment c ON v.entity_id=c.cid JOIN node n ON n.nid=c.nid WHERE n.type='story' GROUP BY v.entity_id;
If you want to get the total numer of votes for all "story" nodes then:
SELECT c.cid,count(v.vote_id) FROM votingapi_vote v JOIN comment c ON v.entity_id=c.cid JOIN node n ON n.nid=c.nid WHERE n.type='story'
Or conditional for voting type like you did:
SELECT c.cid, count(v.value) FROM votingapi_vote v JOIN comment c ON v.entity_id=c.cid JOIN node n ON n.nid=c.nid WHERE n.type='story' and v.value_type='points' GROUP BY v.entity_id;
SELECT c.cid, count(v.value) FROM votingapi_vote v JOIN comment c ON v.entity_id=c.cid JOIN node n ON n.nid=c.nid WHERE n.type='story' and v.value_type='points' GROUP BY v.entity_id;
Please modify answer and I'll accept it. Thanks a lot.
– Jand
Nov 9 '15 at 14:43
story
or just particular one? – Paul Bönisch Nov 9 '15 at 8:18