title: MySQL Pivot Table Column Data as Rows
body: <p>I'm struggling to find a solution this MySQL problem. I just can't seem to get my head around how to do it. I have the following tables.</p>
  
  <pre><code>Question table
  +----+-------------+
  | id | question    |
  +----+-------------+
  | 1  | Is it this? |
  | 2  | Or this?    |
  | 3  | Or that?    |
  +----+-------------+
  
  Results Table
  +----+---------+--------+
  | id | user_id | job_id |
  +----+---------+--------+
  | 1  | 1       | 1      |
  | 2  | 1       | 3      |
  | 3  | 2       | 3      |
  +----+---------+--------+
  
  Answers table
  +----+-------------------------+--------------+
  | id | answer | fk_question_id | fk_result_id |
  +----+-------------------------+--------------+
  | 1  | Yes    | 1              | 1            |
  | 2  | No     | 2              | 1            |
  | 3  | Maybe  | 3              | 1            |
  | 4  | Maybe  | 1              | 2            |
  | 5  | No     | 2              | 2            |
  | 6  | Maybe  | 3              | 2            |
  | 7  | Yes    | 1              | 3            |
  | 8  | Yes    | 2              | 3            |
  | 9  | No     | 3              | 3            |
  +----+-------------------------+--------------+
  </code></pre>
  
  <p>If possible I'd like to display the question answers as columns for each result set, like this.</p>
  
  <pre><code>+-----------+---------+--------+-------------+----------+----------+
  | result_id | user_id | job_id | Is it this? | Or this? | Or that? |
  +-----------+---------+--------+-------------+----------+----------+
  | 1         | 1       | 1      | Yes         | No       | Maybe    |
  | 2         | 1       | 3      | Maybe       | No       | Maybe    |
  | 3         | 2       | 3      | Yes         | Yes      | No       |
  +-----------+---------+--------+-------------+----------+----------+
  </code></pre>
  
  <p>Any help would be much appreciated.</p>
  
  <p>Thanks</p>