What is the SQL to detect if a user has cast a vote in a poll?


(Brian Adams) #1

Working on a badge for civic duty…

Thanks in advance!


(Gerhard Schlager) #2

Take a look at the table plugin_store_rows. The key column contains the votes.
The following query returns the vote for { user_id: 1, post_id: 63 }:

SELECT *
FROM plugin_store_rows
WHERE plugin_name = 'poll' AND key = 'poll_vote_' || 63 || '_' || 1;