Calculating percent of votes inside mysql statement.
Posted
by Beck
on Stack Overflow
See other posts from Stack Overflow
or by Beck
Published on 2010-05-23T11:10:49Z
Indexed on
2010/05/23
11:30 UTC
Read the original article
Hit count: 196
UPDATE polls_options SET `votes`=`votes`+1, `percent`=ROUND((`votes`+1) / (SELECT voters FROM polls WHERE poll_id=? LIMIT 1) * 100,1)
WHERE option_id=?
AND poll_id=?
Don't have table data yet, to test it properly. :)
And by the way, in what type % integers should be stored in database?
Thanks for the help!
© Stack Overflow or respective owner