select t.service_id, t.prod_id, t.prod_name, t.prod_type, t.buss_type, t.pricing_fee, t.detail from TB_BUS_PROD_ACTIVITY_INFO t where 1=1 <if test="prod_id!=null and prod_id!=''"> and t.prod_id in <foreach item="item" index=&
需求:查出给定id的记录: <select id="getEmpsByConditionForeach" resultType="com.test.beans.Employee"> SELECT * FROM tb1_emplyee WHERE id IN <foreach collection="list" item="item_id" separator="," open="
<delete id="deleteByParam"> DELETE FROM YZ_SECURITIES_CURRENCY WHERE ID IN <foreach collection="array" item="id" open="(" separator="," close=")"> #{id} </foreach> </delete&g
MyBatis的Mapper文件的foreach标签用来迭代用户传递过来的Lise或者Array,让后根据迭代来拼凑或者批量处理数据.如:使用foreach来拼接in子语句. 在学习MyBatis Mapper文件的foreach标签时我们先看看DTD是如何定义的?DTD代码如下: <!-- 定义foreach元素 --> <!ELEMENT foreach (#PCDATA | include | trim | where | set | foreach | choose | if |
有时候开发中需要根据多个ID去查询,可以将ID封装为List或者数组然后使用MyBatis中的foreach标签构建in条件. 这里我将ID封装为String[]作为参数. <select id="selectList" parameterType="java.util.List" resultType="java.lang.Integer"> SELECT COUNT(1) FROM t_user WHERE id IN <f