title: join three tables for nested report
body: <p>I am trying to find a way to properly write a query to get the student answers for each question. I am not very good with SQL so I appreciate any help. This is for a student report I am building in PHP/MySQL</p>
  <p>Firstly I have a question_table which stores the questions.
  structure is:</p>
  <pre><code>id
  question
  </code></pre>
  <p>Then I have a student table which has the student details.
  structure is</p>
  <pre><code>id
  student_name
  </code></pre>
  <p>Then I have an answers table, which contains each question_id and student_id.
  structure is:</p>
  <pre><code>id
  question_id
  student_id
  answer
  </code></pre>
  <p>I want to create a report where for each listed question. It shows the answer for each student. Something like:</p>
  <pre><code>Question: What is the name of the largest planet in the Solar System
  Student A: Jupiter
  Student B: Jupiter
  Student C: Saturn
  </code></pre>
  <p>I have tried below but it does not work correctly...:</p>
  <pre><code>select * from question, student
  inner join answer
  where answer.question_id = question.id
  </code></pre>
  <p>Another challenge is that the report should be paginated. So first 20 questions per page. If a question has multiple student answers then the count will be more and I am not sure how I can paginate this correctly :(</p>