私はこのMySQLの問題の解決策を見つけるのに苦労しています。私はそれをどうやってやるのか頭を悩ませているようには思えません。次の表があります。
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 |
+----+-------------------------+--------------+
可能であれば、このように、質問の回答を各結果セットの列として表示したいと思います。
+-----------+---------+--------+-------------+----------+----------+
| 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 |
+-----------+---------+--------+-------------+----------+----------+
どんな助けでも大歓迎です。
ありがとう