Hi, got a question regarding a MySQL database. The database is for tracking online votes. The table is simple:
VoteID
VoteDate
UserName (of person voting)
(Then 8 fields of candidates) if voted for field will contain a YES otherwise it's blank.
VoteSara
VoteDan
VoteTom
VoteJack
VoteJane
VoteMark
VoteCindy
VoteLori
I need to count the votes for each person. I can do:
Which works fine for that one person, I would like to be able to write ONE SQL Statement / Procedure that would count all the votes for each person. Any thoughts or suggestions? I am thinking an array and for loop, but not sure how to do that.
Also, you can only select up to 6 of the 8 candidates. So some rows have 6 YES, others only selected 1 or 2 people.
Thanks!
Dan
VoteID
VoteDate
UserName (of person voting)
(Then 8 fields of candidates) if voted for field will contain a YES otherwise it's blank.
VoteSara
VoteDan
VoteTom
VoteJack
VoteJane
VoteMark
VoteCindy
VoteLori
I need to count the votes for each person. I can do:
Code:
SELECT count(VoteSara) FROM `AHOF_Vote_Tbl` WHERE VoteSara = 'YES'
Also, you can only select up to 6 of the 8 candidates. So some rows have 6 YES, others only selected 1 or 2 people.
Thanks!
Dan
Comment