当前位置:Gxlcms > 数据库问题 > mysql批量插入,批量更新

mysql批量插入,批量更新

时间:2021-07-01 10:21:17 帮助过:22人阅读

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

<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批量插入,批量更新

标签:data   open   parameter   char   class   批量操作   判断   div   数组   

人气教程排行