mysql 删除多个字段重复的数据, 只保留最新的一条

delete from tableName where keyName not in (
    select keyName from (
    select keyName from (select keyName,CONCAT(字段1,字段2,modifyTime) as uam from tableName) as temp where temp.uam in (
      select CONCAT(字段1,字段2,max(modifyTime)) from tableName group by 字段1,字段2 
    )  
  ) temp2
 )

 

posted @ 2021-08-26 11:08  李小加  阅读(476)  评论(0编辑  收藏  举报