我有一个看起来像这样的表,称为survey_1:
================================================
|id | token | 1X2X1 | 1X2X2 |
=====+========+===============+================|
| 1 | 1 | YES | Justin Beiber |
|----+--------+---------------+----------------|
| 2 | 1 | YES | Britney Spears |
|----+--------+---------------+----------------|
注意:1X2X1 代表-survey-id X group-id X question-id
我有另一个表叫survey_questions:
===============================================================
|sid | gid | qid | question |
=====+========+===============+===============================|
| 1 | 2 | 1 | Do you listen to music? |
|----+--------+-----------------------------------------------|
| 1 | 2 | 2 | Who is your favorite music artists? |
|----+--------+-----------------------------------------------|
sid (survey-id)、gid (group-id) 和 qid(question-id) 定义此表中的特定问题
我需要一个查询,它会给我这样的结果:
======================================================
| Question | Answer |
=========+===========+===============================|
| Do you listen to music? | YES |
|----------------------------------------------------|
| Who is your favorite music artists? | Justin Beiber|
|----------------------------------------------------|
注意:我的数据库包含数千个这样的列,因此编辑每个调查以完全匹配这种格式会非常耗时。
有人可以帮忙吗?谢谢