0

我有一张表格,用于存储调查结果。我必须编写一个程序,将这些调查的反馈表化,并将其插入到数据库的另一个表中。

唯一的问题是在新数据库中每个问题都有自己的列,在源表中我将它们列在行中。所以每个答案在数据库中都有不同的行。

我创建了当前表的小提琴以及测试反馈结果。

http://sqlfiddle.com/#!2/bda665/1

能够知道数据库中不同的反馈account_id、completed_by、completed_on但是是一样的。

从小提琴的结果应该是这样的

INSERT INTO feedback_final(Q21, Q22, Q23, Q24, Q25, Q26, Q27, Q29, completed_by, completed_on, account_id)
    Answer for Question 21 '2053'
    Answer for Question 22 'ANSWER: Describe Practice Experience with Financing'
    Answer for Question 23 '67;68;70'  -- notice here because the question_ID id the same I have to merge the results with a simi-colon
    Answer for Question 24 '7'
    Answer for Question 25 '755555'
    Answer for Question 26 '3'
    Answer for Question 27 '75'
    Answer for Question 29 'This is an action plan'
    completed_by
    completed_on
    account_id

这将允许我将每个答案插入到不同的列中。

我该如何解决这个问题?

谢谢

4

0 回答 0