1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Filtering poll votes

Discussion in 'XenForo Questions and Support' started by Darfuria, Jun 11, 2011.

  1. Darfuria

    Darfuria Active Member

    The voting for a pretty hefty competition was foolishly run through a poll on a forum I administrate. The unfortunate result was of course that people signed up for multiple accounts to vote on the poll more than once.

    Through executing an SQL query, would there be a way of me getting results of the poll based on unique IP addresses, or only counting people who have a postcount greater than 0?
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    IPs aren't logged for poll votes. The best you can hope to do is select unique votes based on users' other IP history. It's not an ideal solution. And I don't have a query for this.

    Here is a query for that:

    SELECT pr.response, COUNT(*)
    FROM xf_poll_vote AS pv
    LEFT JOIN xf_poll_response AS pr ON (pr.poll_response_id = pv.poll_response_id)
    LEFT JOIN xf_user AS u ON (u.user_id = pv.user_id)
    WHERE pv.poll_id = 1
    AND u.message_count > 0
    GROUP BY pv.poll_response_id
    You need to specify the pollid (WHERE pv.poll_id = 1).

    You will get results like this:

    Screen shot 2011-06-11 at 6.29.41 AM.png
  3. Darfuria

    Darfuria Active Member

    That's great Jake! Thanks so much

Share This Page