mapper.xml 循环 ibatis
循环: < select id= "searchPriceFour" resultType= "java.util.HashMap" > < foreach collection= "list" index= "index" item= "item" open= "(" separator= "UNION ALL" close= ")" > select * from 表 where bak1 = #{item} </ foreach > </ select > 这是一个循环,service传来list集合。 item是个数组,比如:【“大宗”,“其他”】 open=”(” separator=”union all” close=”)的意思:以“(”开始,中间用“union all”链接,以“)”结束。 结果:(select * from 表 where bak1 = ‘大宗’) UNION ALL (select * from 表 where bak1 = ‘其他’) 文章来源: mapper.xml 循环 ibatis