Post

mysqlで既に登録されている値を置換して再登録

REPLACE を利用する。

update
  users,
  (
    select
      id
    from
      users
    where
      name regexp ' '
  ) as having_spaces
set
  name = REPLACE(name, " ", "")
where
  users.id = having_spaces.id
This post is licensed under CC BY 4.0 by the author.