1、首先,您需要准备好要插入的数据,并将其存储在一个数组中;
2、然后,使用foreach语句遍历数组,并将每一条数据拼接到一条INSERT语句中;
3、最后,使用MySQL的execute()函数执行这条INSERT语句,完成数据插入 *** 作。
<delete id="deleteUser" parameterType="list">delete from user where id in
<foreach collection="list" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="findUserBySex" resultType="user">
select * from user where name in
<foreach collection="roleNoList" item="name" index="index" open="(" separator="," close=")">
#{roleNo}
</foreach>
</select>
<insert id="addUser" parameterType="user" >
insert into user(name,id,code) values
<foreach collection="list" item="item" separator=",">
(#{item.name},#{item.id},#{item.code})
</foreach>
</insert>
<update id="updateUser" parameterType="user">
update user set a = #{fptm},b=#{csof} where c in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</update>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)