1. 程式人生 > >myBatis查詢報錯 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near

myBatis查詢報錯 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near

myBatis查詢報錯

   You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near

<select id="selectList" parameterType="com.hanilucky.core.vo.Dep"
        resultMap="BaseResultMap">
        select
        <include refid
="Base_Column_List" /> from dep <where> <if test="uuid != null"> AND UUID = #{uuid,jdbcType=INTEGER} </if> <if test="name != null and name != ''"> AND NAME = #{name,jdbcType=VARCHAR}
</if> <if test="tele != null and tele != ''"> AND TELE = #{tele,jdbcType=VARCHAR} </if> </where> </select>

標紅的NAME是mysql的關鍵字,解析時報錯

修改時加上``引用(數字1左邊的鍵)

<select id="selectList" parameterType="com.hanilucky.core.vo.Dep"
resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> from dep <where> <if test="uuid != null"> AND UUID = #{uuid,jdbcType=INTEGER} </if> <if test="name != null and name != ''"> AND `NAME` = #{name,jdbcType=VARCHAR} </if> <if test="tele != null and tele != ''"> AND TELE = #{tele,jdbcType=VARCHAR} </if> </where> </select>