mapper.xml 循环 ibatis

匿名 (未验证) 提交于 2019-12-03 00:19:01

循环:

<select id="searchPriceFour" resultType="java.util.HashMap"> <foreach collection="list" index="index" item="item" open="(" separator="UNION ALL" close=")">         select * fromwhere bak1 = #{item} </foreach> </select>

这是一个循环,service传来list集合。
item是个数组,比如:【“大宗”,“其他”】
open=”(” separator=”union all” close=”)的意思:以“(”开始,中间用“union all”链接,以“)”结束。
结果:(select * from 表 where bak1 = ‘大宗’) UNION ALL (select * from 表 where bak1 = ‘其他’)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!