业务场景需求:
12个月使用12张不同的表,操作表时,希望只使用单条sql操作多张表
引入字符:$
使用方法和#一致,使用时,直接将表名作为参数传入。
举个例子:
另外附上万能模板,包含排序:
<update id="updateByLowerChangeHigh" parameterType="map" statementType="STATEMENT">
update ${tableName} set ${sqlName} = ${sqlName} -1 where 1 = 1
<if test="startNo != null and endNo!=null">
and ${sqlName} between ${startNo} and ${endNo}
</if>
<if test="sqlName2!=null">
and ${sqlName2}
</if>
and school_num = ${schoolNum}
</update>
<update id="updateByHighChangeLower" parameterType="map" statementType="STATEMENT">
update ${tableName} set ${sqlName} = ${sqlName} +1 where 1 = 1
<if test="startNo != null and endNo!=null">
and ${sqlName} between ${startNo} and ${endNo}
</if>
<if test="sqlName2!=null">
and ${sqlName2}
</if>
and school_num = ${schoolNum}
</update>