天天看點

資料庫表中有重複記錄,如何删除這些重複記錄保留ID最大的一個資訊

delete from tc_Table  

WHERE (account_name IN  

  (SELECT account_name  

  FROM tc_Table  

  GROUP BY account_name  

  HAVING COUNT(account_name) > 1))  

 and id not in (select min(id) from tc_Table group by account_name having count(tc_Table)>1)