美文网首页JAVA自我总结
Mybatis批量插入或更新(基于唯一索引)

Mybatis批量插入或更新(基于唯一索引)

作者: Coderlifesunny | 来源:发表于2019-01-29 11:00 被阅读0次
    <insert id="batchInsertOrUpdate">
    
      insert into supplier_quotation_goods (supplier_account, project_serial_number, goods_id, goods_name, quotation_price, quotation_quantity, status, created, modified, yn) VALUES
    
      <foreach collection="list" item="record" separator=",">
    
        (#{record.supplierAccount}, #{record.projectSerialNumber}, #{record.goodsId}, #{record.goodsName}, #{record.quotationPrice}, #{record.quotationQuantity}, 0, now(), now(), 1)
    
      </foreach>
    
      ON DUPLICATE KEY UPDATE
    
      quotation_price=values(quotation_price),quotation_quantity=values(quotation_quantity),modified=now()
    
    </insert>
    

    相关文章

      网友评论

        本文标题:Mybatis批量插入或更新(基于唯一索引)

        本文链接:https://www.haomeiwen.com/subject/dxztsqtx.html