Remove duplicate records based on multiple columns?

前端 未结 7 1960
灰色年华
灰色年华 2020-12-04 07:46

I\'m using Heroku to host my Ruby on Rails application and for one reason or another, I may have some duplicate rows.

Is there a way to delete duplicate records base

相关标签:
7条回答
  • 2020-12-04 08:14

    You can try this sql query, to remove all duplicate records but latest one

    DELETE FROM users USING users user WHERE (users.name = user.name AND users.year = user.year AND users.trim = user.trim AND users.id < user.id);
    
    0 讨论(0)
提交回复
热议问题