I used to have 3 tables: users, polls, and choices. I used one INNER JOIN query to get all choices by a specific user ID, and then I matched the poll.id with choice.pollid. I got that to work and I was happy with it, but now I'm implementing a 4th table, votes, where I will store vote id, choice id, IP, and (if logged in), user id.
My initial query:
PHP Code:
$qry = 'SELECT p.id, p.question, p.date, p.active, c.choice, c.votecount, c.pollid, c.id
FROM polls p
INNER JOIN choices c ON c.pollid = p.id
WHERE p.userid = ' . $currentid . '
ORDER BY p.date DESC';
I slightly modified it but it doesn't work, and I can't find the syntax for multiple joins.
PHP Code:
SELECT p.id, p.question, p.date, p.active, c.choice, c.votecount, c.pollid, c.id, v.id
FROM polls p
INNER JOIN choices c ON c.pollid = p.id
WHERE p.userid = 1000
INNER JOIN votes v ON v.pollid = p.id
WHERE p.id = 1
ORDER BY p.date DESC
In essence, I want to pull every vote on every poll by a specific userid. And then I'll probably store that data in multi-dimensional arrays and then reference it later (?).