您现在的位置是:

sql删除相同数据保留其中一个

发布时间:2021-09-03作者:小灵龙来源:未知点击:117

把同个相同字段的表合并成一个表,数据有相同的,把其中一个id最小的删除,留下id最大的一条数据。

delete from member where id in
(
    select a.id from
    (
        select min(id) id from member a where EXISTS
        (
            select 1 from member b where a.mid=b.mid group by mid HAVING count(*)>1
        )
        group by mid
    ) a
)

如果帮到了您,请打赏一二!

标签: