Home  >  Q&A  >  body text

mysql summarizes multiple data into one data

3 tables
1. Question table tbl_question
id, fk_qnid (questionnaire id, unified to 1), questionName
2. Question option table tbl_answer
id, fk_qnid (questionnaire id, unified is 1), fk_qid (question id), answerName (option name)
3. Questionnaire answer table tbl_question_deail
id, openid (unique identification of the answering user), fk_qnid (questionnaire id, unified to 1), fk_qid( question id), fk_aid (answer id), remark (questionnaire questions are not multiple-choice questions, but records of fill-in-the-blank questions)


The actual data is as shown above
When the user fills in the questionnaire, there will be one more record for the single-choice question. If the user selects multiple choices for the multiple-choice question, there will be more records. Answer questions If fk_aid is empty, remark records the answer filled in by the user.
According to this table, how to obtain the answer status of each user
How to write the sql statement so that each user can have one row of data. Multiple selection can be used Comma separated

怪我咯怪我咯2689 days ago831

reply all(1)I'll reply

  • phpcn_u1582

    phpcn_u15822017-06-08 11:05:28

    Questions without test data are just hooligans

    reply
    0
  • Cancelreply