MySQL重复记录删除

      一种诡异的写法:

delete t  
from t, 
( select table_name,max(id) id 
  from t 
  group by table_name 
  having count(*)>1 ) d 
where t.table_name=d.table_name 
  and t.id<d.id;

      没见过这种语法,记录一下。

posted @ 2011-12-22 11:50  killkill  阅读(637)  评论(1编辑  收藏