MySQL中的group_concat问题

时间:2015-02-08 05:23:57

标签: mysql group-concat

我有这个问题:

SELECT
form.id AS `Form ID`,
 GROUP_CONCAT(IF(questions = 'Area:',answer, NULL)) AS Area,
 GROUP_CONCAT(IF(questions = 'Number of Local Hires:', answer, NULL)) AS `Number of Local Hires`,
 GROUP_CONCAT(IF(questions = 'Dates:', answer, NULL)) AS Dates,
 GROUP_CONCAT(IF(questions = 'Salary Per Local Hire Per Day:', formanswer.answer, NULL)) AS `Salary Per Local Hire Per Day`,
 GROUP_CONCAT(IF(questions = 'Amount:', answer, NULL)) AS Amount
FROM
form
INNER JOIN formquestions ON formquestions.forms_id = form.id
INNER JOIN formanswer ON formanswer.formsquestion_id = formquestions.id
WHERE
form.id = 2 AND
form.id = formquestions.forms_id AND
formanswer.formsquestion_id = formquestions.id

结果是正确的,但我希望它在另一行。我尝试将它分组,但仍然没有工作。

这是迄今为止的输出。query result

表: 形式,形式,形成顺序。

form formquestions formanswer

预期输出将是:

Form ID | Area | Number of Local Hires | Dates |
2          CBR    ...                    ...  
2          DVO    ...                    ...

0 个答案:

没有答案