Hi, I'm trying to create a simple poll function using php and sql. I have three tables:
Questions
Which simply contains each question asked
question_id | question_text | created_at
Answers
Which contains each answer for each question
question_id | answer_id | answer_text
Answered Questions
Which records who has voted for each option
question_id | answer_id | user_ip
I'm trying to write a query which will return a single question (the most recent) along with all the possible answers to that question and finally a count of each answer to each question. I know I will have to use a GROUP BY clause and possible LEFT OUTER JOIN, but the exact syntax is eluding me atm.
Any advice would be greatly appreciated. Thanks.