影落离风

The shadow falls away from the wind

0%

sql批量修改脚本模板

  1. 批量修改

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    -- 批量修改
    update user e,
    (
    -- 拼接需要的字符串
    select c.id, c.new_name
    from (select id,
    substring_index(name, '_', 1) new_name
    from user
    ) c
    ) a
    set name = a.new_name
    where e.id = a.id
    -- 判断符合条件的字符串
    and LENGTH(SUBSTRING_INDEX(substring_index(name, '_', 2), '_', - 1)) = 3;