直接上代码()
<update id="updatemore" >
update
${conditiontabletype}
<trim prefix="set" suffixOverrides=",">
<trim prefix="name =case" suffix="end,">
<foreach collection="list" item="item" index="index">
when ip = #{item.conditionip} then #{item.name}
</foreach>
</trim>
<trim prefix="ip =case" suffix="end,">
<foreach collection="list" item="item" index="index">
when ip = #{item.conditionip} then #{item.ip}
</foreach>
</trim>
。。。
。。。
</trim>
where ip in
<foreach collection="list" index="index" item="item" separator="," open="(" close=")">
#{item.conditionip}
</foreach>
</update>
基于sql:
update mytablename set
colname1 = case
when colname2 = ? then youValue1
when colname2 = ? then youValue2
when colname2 = ? then youValue3
end,
colname3 = case
when colname2 = ? then youValue4
when colname2 = ? then youValue5
when colname2 = ? then youValue6
end,
...
where colname2 in (?,?,?)