I have 3 tables in a mysql database.
These tables together, form a QuickPoll structure, that looks like this:
table 1)
poll_base:
id, headline, date
table 2)
poll_option:
id, ref_base_id, text
table 3)
poll_voters:
ref_option_id, user_id
From these three tables, I would like to display:
Headline
Options (a WHILE loop with poll_options)
Number of votes on a poll_option (WHILE loop from poll_voters)
I order to obtain these outputs, I use the following MySQL query:
SELECT
COUNT(voters.ref_option_id) AS votes,
options.text AS options,
options.id AS option_id
FROM
hp_poll_option options,
hp_poll_voters voters,
hp_poll_base base
WHERE
options.ref_base_id = base.id
AND
options.id = voters.ref_option_id
AND
WEEK(base.dato, 3) = WEEK(NOW(), 3)
GROUP BY
options.id
The problem is this. If a poll_option has NO votes from poll_voters, this option does not SELECT (or display) in the query.
How can I change this?