更新时间:2023-12-01 11:35:40
此查询将返回所有重复的ids,并以逗号分隔的ids名称共享相同的名称:
This query will return all duplicated ids with a comma separated list of ids that share the same name:
select
t1.id,
group_concat(t2.id)
from
tablename t1 inner join tablename t2
on t1.id<>t2.id and t1.name=t2.name
group by
t1.id
,此查询将更新说明:
update tablename inner join (
select
t1.id,
group_concat(t2.id) dup
from
tablename t1 inner join tablename t2
on t1.id<>t2.id and t1.name=t2.name
group by
t1.id
) s on tablename.id = s.id
set
description = concat('duplicate id in (', s.dup, ')')
请看一个工作小提琴在这里。