mybatis $ 和 # 的区别


第一种写法:

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

第二种写法:

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

 

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

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

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