delete from tbname 
where rowid not in (select min(rowid) from tb group by col1,col2..);not in的效率很慢,也可以这样:
delete from tbname 
where rowid <(select max(rowid) from tb group by col1,col2..);
还可以这样:
delete from tablename a
where rowid >(select min(rowid) from table b where condition ...);

解决方案 »

  1.   

    delete from REQUEST where rowid not in
       (select max(rowid) from REQUEST group by id)
      

  2.   

    delete tablename a
     where a.rowid <> (select max(rowid) from tablename b where a.id=b.id);
    会快一点
      

  3.   

    http://www.anysql.net/article/deldup.html
      

  4.   

    to  zzwind5() :
    使用不等于怎么会比>和<快呢?
      

  5.   

    晕 ,关键字from都没有了delete from table t1 where rowid !=
    (
    selec max(rowid) from table t2 where t1.id = t2.id
    )
      

  6.   

    如果我想要把有重复的都删掉,就是有一样id的都删掉
    delete from table where (
    select count(*) from table group by id  
    ) > 1
      

  7.   

    重复的都删掉,就是有一样id的都删掉可以这样 
    delete from table where id in 
    (select id from table t1 where rowid !=
    (select max(rowid) from table t2 where t1.id = t2.id)
    )
      

  8.   

    能不能讲解一下delete from REQUEST where rowid not in
       (select max(rowid) from REQUEST group by id)这句话的意思
      

  9.   

    To:cnepine(奔)
      rowid 是表里系统自带的一个唯一字段名,group by id 按id分组以后同id的纪录的rowid不一样,从而可以根据rowid的不同把同id的记录找出来