Skip to content

Instantly share code, notes, and snippets.

@ramigb
Created January 2, 2014 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramigb/8217446 to your computer and use it in GitHub Desktop.
Save ramigb/8217446 to your computer and use it in GitHub Desktop.
Reset voting counts
UPDATE `votes_items` c
INNER JOIN (
SELECT `vote_id`, COUNT(`vote_id`) as total
FROM `votes`
GROUP BY `vote_id`
) x ON c.id = x.vote_id
SET c.votes_counter = x.total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment