美文网首页
mysql 根据单列删除重复记录sql

mysql 根据单列删除重复记录sql

作者: _嘛喳喳_ | 来源:发表于2019-07-18 09:17 被阅读0次
    DELETE FROM [table_name]
    WHERE [column_name]  IN ( 
    select [column_name] from (
        SELECT [column_name] FROM  [table_name] GROUP BY [column_name] HAVING count([column_name]) > 1 
    ) a
    )
    AND id NOT IN (
    select minid from (
        SELECT min(id) as minid FROM [table_name] GROUP BY [column_name] HAVING count([column_name]) > 1) b
    )

    相关文章

      网友评论

          本文标题:mysql 根据单列删除重复记录sql

          本文链接:https://www.haomeiwen.com/subject/ttkklctx.html