sql insert的时候顺便update,on duplicate key update 的用法

 

    INSERT INTO channel_booking_ixd (
        booking_id,
        task_id,
        task_no,
        latest_leave_time,
        update_time
    )
    VALUES
    <foreach collection="list" item="item" index="index" separator=",">
        (
        #{item.bookingId},
        #{item.taskId},
        #{item.taskNo},
        #{item.latestLeaveTime},
        #{item.updateTime}
        )
    </foreach>
        on duplicate key update
        update_time=VALUES(update_time),
        latest_leave_time = VALUES(latest_leave_time)
</insert>

 

posted @ 2020-08-19 11:52  君子笑而不语  阅读(613)  评论(0编辑  收藏  举报