使用left on保存,请问如何结局
<select id="selectByUserAndStatusV2" resultType="cn.spring.inter.entity.CodeTask">
SELECT
<include refid="Base_Column_List" />,
td.explanation AS taskDifficulty,
cc.name AS taskType
FROM code_task ct
-- task_status ts,
-- task_difficulty td
LEFT JOIN task_status ts on ct.status= ts.id
LEFT JOIN task_difficulty td on ct.difficulty = td.id
LEFT JOIN cad_classify cc ON ct.type = cc.id
<where>
-- AND ct.status = ts.id
-- AND IFNULL(ct.difficulty, 0) = td.id
-- AND IFNULL(ct.type, 0) = cc.id
<if test="userID != null">
AND ct.userID = #{userID}
</if>
<if test="flagDelete != null">
AND flag_delete = #{flagDelete}
</if>
<if test="statusList!=null and statusList.size()>0">
AND ct.status in
<foreach collection="statusList" item="item" index="index" open="(" separator="," close=")">
replace('${item}',' ','')
</foreach>
</if>
</where>
<choose>
<when test="sort=='ASC'">
order by id ASC limit #{start}, #{dataLength}
</when>
<otherwise>
order by id DESC limit #{start}, #{dataLength}
</otherwise>
</choose>
</select>
使用<where>标签mybatis会帮你去掉AND ct.userID = 2前的AND,如果只是用了sql的where,不会帮你去掉,生成的sql为 select .... from table where AND ct.userID = 2 ,所以报sql语法问题。