首页 > 数据库技术 > 详细

mysql批量插入,批量更新

时间:2017-12-07 20:06:31      阅读:307      评论:0      收藏:0      [点我收藏+]

进行批量操作的时候,一定要事先判断数组非空

<insert id="batchInsert"parameterType="java.util.List"> 
insert into DATA (ID, TEXT, STAUTS) 
<foreach close=")"collection="list"item="item"index="index"open="("separator="union"> 
select 
#{item.id,jdbcType=VARCHAR}, 
#{item.text,jdbcType=VARCHAR}, 
#{item.stauts,jdbcType=VARCHAR} 
from dual 
</foreach> 
</insert>
AND r.license_plate IN
				<foreach collection="rdRiskEventInfoList" item="item" index="index" open="(" separator="," close=")">
					#{item}
				</foreach>

  

update rd_risk_event_info SET truck_risk_id=#{id, jdbcType=VARCHAR} where id in
		<foreach item="item" index="index" collection="idList" open="("
			separator="," close=")">
			#{item.id}
		</foreach>

  

mysql批量插入,批量更新

原文:http://www.cnblogs.com/lazyInsects/p/8000469.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!