Mybatis批量新增并根据主键更新

单句新增:

 
        INSERT INTO  lost_player_item_info (
            player_id,
            func_id,
            item_id,
            item_num)
        VALUES 
                #{playerId,jdbcType=BIGINT},
                #{funcId,jdbcType=BIGINT},
                #{itemId,jdbcType=INTEGER},
                #{itemNum,jdbcType=INTEGER}
             
        ON DUPLICATE KEY UPDATE
        item_num = #{itemNum,jdbcType=INTEGER}

批量新增:(格式:VALUES(xx))

 
        INSERT INTO  lost_player_item_info (
            player_id,
            func_id,
            item_id,
            item_num)
        VALUES
        
            (
                #{item.playerId,jdbcType=BIGINT},
                #{item.funcId,jdbcType=BIGINT},
                #{item.itemId,jdbcType=INTEGER},
                #{item.itemNum,jdbcType=INTEGER}
            )
        
        ON DUPLICATE KEY UPDATE
        item_num = VALUES(item_num)

    

 

你可能感兴趣的:(数据集)