Hello everyone 🙂
Guys... I don't know what I'm doing wrong in this search :S... I'm creating this poll system to my website. when I do a simple search like:
SELECT poll.poll_question, COUNT(poll_votes.vote_optionID)
FROM poll
LEFT JOIN poll_votes ON poll_votes.vote_questionID = poll.poll_questionID
WHERE poll.poll_questionID = 9
GROUP BY poll_votes.vote_optionID
I get the right results: 9 / 11 / 12.
The problem is that I need more results in the same query. And that is making the last record of my votes to be multiplied by 3 :S.
SELECT poll.poll_questionID, poll.poll_type, poll.poll_question, poll.poll_description, poll.poll_closedate,
user_registered.user_name,
poll_options.option_optionID, poll_options.option_title,
COUNT(poll_votes.vote_optionID) AS votes
FROM poll
LEFT JOIN user_registered ON poll.poll_author = user_registered.user_userID
LEFT JOIN poll_opts ON poll.poll_questionID = poll_opts.questionID
LEFT JOIN poll_options ON poll_opts.optionID = poll_options.option_optionID
LEFT JOIN poll_votes ON poll_options.option_optionID = poll_votes.vote_optionID
WHERE poll.poll_questionID = 9
GROUP BY poll_options.option_optionID
I get: 9 / 11 / 36.
I dont know what I'm doing wrong, I've tried several different connections. If you guys can see what I'm doing wrong I would appreciate a lot the help... you know when you're working too long on the same subject you tend not to see the error.
The attachment has the poll table scheme. I hope I did it right :S
Anyway thanks in advance everyone 🙂