「質問」をクエリし、「回答」と結合しています。各質問には、2 つ以上の回答がある場合があります。そのため、返される質問の数に回答の数が掛けられています。これにより、ページネーションを実装できなくなります。どうすればこれを回避できますか? ありがとう。
これが私のクエリです:
<cfquery name="questions">
SELECT
questions.id as questionid,
questions.question as question,
questions.rank as rank,
questions.isrequired as isrequired,
questiontypes.id AS questiontypeid,
questiontypes.name as questiontype,
questiontypes.template as template,
questions.survey_id as survey_id,
surveys.name as surveyname,
surveys.questionsperpage as questionsperpage,
surveys.thankyoumsg as thankyoumsg,
answers.id as answerid,
answers.answer as answer
FROM
questions
LEFT JOIN answers ON answers.question_id = questions.id
INNER JOIN questiontypes ON questions.questiontype_id = questiontypes.id
INNER JOIN surveys ON questions.survey_id = surveys.id
WHERE
questions.survey_id = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.surveyid#">
</cfquery>