<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper 
PUBLIC 
	"-//mybatis.org//DTD Mapper 3.0//EN" 
	"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- 命名，每一个映射对象不一样
	namespace:必须与对应的接口全类名一致
 -->
<mapper namespace="com.iamberry.wechat.service.mapper.QuestionnaireAnswerDetailedMapper">
	<sql id="questionnaireAnswerDetailed">
		Q.DETAILED_ID detailedId,
		Q.DETAILED_QUESTION_ID detailedQuestionId,
		Q.DETAILED_OPTION_ID detailedOptionId,
		Q.DETAILED_ANSWER_ID detailedAnswerId,
		Q.DETAILED_CREATE_DATE detailedCreateDate,
		Q.DETAILED_SCORE detailedScore,
		Q.DETAILED_STATUS detailedStatus
	</sql>
	
	<!-- 根据所属数据id查询用户回答详细信息 -->
	<select id="getAnswerDetailed" parameterType="Integer" resultType="QuestionnaireAnswerDetailed">
		SELECT
			<include refid="questionnaireAnswerDetailed" />, 
			T.QUESTION_NAME questionName,
			X.OPTION_NAME optionName,
			X.OPTION_ORDER optionOrder
		FROM
			TB_IAMBERRY_QUESTIONNAIRE_ANSWER_DETAILED Q
			LEFT JOIN TB_IAMBERRY_QUESTIONNAIRE_QUESTION T 
			ON (Q.DETAILED_QUESTION_ID = T.QUESTION_ID)
			LEFT JOIN 
			TB_IAMBERRY_QUESTIONNAIRE_OPTION X 
			ON Q.DETAILED_OPTION_ID = X.OPTION_ID
		WHERE
			Q.DETAILED_ANSWER_ID = ${detailedAnswerId}
	</select>
</mapper>