I have 3 tables. I currently run following query which does not work.
SELECT
a._id,
a.title,
COUNT(DISTINCT user_id)
AS
number_of_participants
FROM
a, b, c
WHERE
a._id=b.fk AND
b._id=c.fk
The field user_id exists only in table c.
Explanation what I want: Table a contains questions, while table b holds the answers with reference fk to the question. And I want to count how many users already have voted for every question. So table c holds the votes.
EDIT: My database scheme:
Table a:
_id integer,
title text
Table b:
_id integer,
title text,
fk integer references a._id
Table c:
user_id text,
name text,
fk integer references b._id
Aucun commentaire:
Enregistrer un commentaire