• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
懒惰虫
博客园    首页    新随笔    联系   管理    订阅  订阅

mysql批量插入,批量更新

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

<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>

  

posted @ 2017-12-07 18:26  懒惰虫  阅读(310)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3