1,条件语句中使用or连接的遍历
<foreach collection="propertyLevelSectionList" item="itr" index="index" separator=" or " open=" and(" close=")">
( a.PROPERTY_LEVEL_ONE = #{itr.propertyLevelOne} and a.PROPERTY_LEVEL_TWO = #{itr.propertyLevelTwo} )
</foreach>
2,insert插入语句时foreach写法
<insert>
insert into 表明(
字段名
)(
<foreach collection="list" item="item" index="index" separator="UNION ALL">
select
字段
from
dual
</foreach>
)
</insert>
3,where条件中某个字段在某一范围collection="areaidSet"(类中集合的名称)
where 字段名 in
<foreach item="item" index="index" collection="areaidSet" open="(" separator="," close=")">
#{item}
</foreach>
4,update:数据更新时的foreach写法
<update>
<foreach collection="list" item="item" index="index" open="begin" close=";end;" separator=";">
</foreach
</update>
sql中几种批量foreach的写法记录
猜你喜欢
转载自blog.csdn.net/qq_34395852/article/details/84287025
今日推荐
周排行