3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MySQLのテーブルに登録済みの文字列をまとめていじる

Posted at

MySQL上に誤って、

xxx, xxx

のような文字列が登録してしまい、これをまとめて

xxx

にしたいなということがありました。

こういう場合、下記のようなSQL一発で全部を置き換えることができます。

UPDATE テーブル名 SET カラム名 = REPLACE(カラム名, カラム名, SUBSTRING_INDEX(カラム名, ',', 1))

SUBSTRING_INDEXで、文字列をカンマ区切りにし、その最初の要素だけを登録し直している感じです。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?