mybatis $ 和 # 的区别

 

第一种写法:

<select id="selectByScIds" resultMap="BaseResultMap" parameterType="com.management.ScRequest">
 select
 <include refid="Base_Column_List" />
 from sc_template
 <where>
   <if test="plcVersion!=null">
    plc_version=#{plcVersion,jdbcType=VARCHAR}
   </if>
   <if test="scIds!=null">
     and sc_id in (${scIds})
   </if>
 </where>
</select>

第二种写法:


<select id="selectByScIds" resultMap="BaseResultMap" parameterType="com.management.ScRequest">
 select
 <include refid="Base_Column_List" />
 from sc_template
 <where>
   <if test="plcVersion!=null">
    plc_version=#{plcVersion,jdbcType=VARCHAR}
   </if>
   <if test="scIds!=null">
     and sc_id in (#{scIds})
   </if>
 </where>
</select>

 

注意看 and sc_id in (${scIds}) 和 and sc_id in (#{scIds}) ;

$ 和 # 的区别 # : (“105011,105012,105013,105004,429063,213020,429062”)

$ : ('105011','105012','105013','105004','429063','213020','429062')

 

posted @ 2022-03-04 18:06  ziperson  阅读(36)  评论(0)    收藏  举报
//雪花飘落效果