我还有一个未在此处显示的员工实体,其中包含我想要包含在我的查询中的ID和名称字段。
我需要创建一个查询,如果给出调查ID,则会返回如下所示的结果列表:
Survey.name | Survey.submitter_id | Survey.subject_id | question.text | survey_questions.answer_value |survey_questions.anonymous
答案 0 :(得分:2)
我无法测试查询,但我认为你会明白这个想法:
SELECT s.name, sq.submitter_id, s.subject_id, q.text, sq.answer_value, sq.anonymous FROM surveys AS s
JOIN survey_questions AS sq ON sq.survey_id = s.id
JOIN questions AS q ON sq.question_id = q.id
WHERE s.id = <your_value>