0
0

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 3 years have passed since last update.

【MySQL】複数のカラムで重複しているデータを見つける方法

Last updated at Posted at 2021-03-29

データ解析に使ったので、メモ
サブクエリ内では、countを実行するだけ。
メインクエリ内では、countが1以上のものは重複していると言えるので、以下のような形でできる。

select * from (
	select concat(column1, '-', column2) as token,
		COUNT(*) as cnt
		FROM table_name GROUP BY (token)
) as contents WHERE cnt > 1;

解析に使っただけだが、実際のプロダクションコードとしてで扱うには、あまりよくない気がする。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?