zoukankan      html  css  js  c++  java
  • 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>
    

      

  • 相关阅读:
    第八章
    第十章
    第九章
    第七章
    第六章
    第五章
    第四章心得
    第二章心得
    第三章心得
    第一章心得
  • 原文地址:https://www.cnblogs.com/lazyInsects/p/8000469.html
Copyright © 2011-2022 走看看