现在发现混合数据很多的重复记录

id  a
111  1
111  2现在我需要保留任意一条 ,如111  1  这一个就可以
其他的要delete掉
如何写这个 delete语句?

解决方案 »

  1.   

    delete a from yourTable a,yourTable b where a.id=b.id and a.a>b.a;
    当您的问题得到解答后请及时结贴.
    http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
      

  2.   

    抱歉 现在完全id  a 
    111  1 
    111  1 
    222  2
    222  2需要改写这个sql 
      

  3.   

    这个需要找到你的表中的两条记录的唯一标识(如主键)来删除,就你给的这种情况,我看是不能给出sql
      

  4.   

    这种情况,两条记录所有字段相同,没有办法进行删除!
    只能select distinct * from yourTable 
    得到一个不重复的。然后清空原表。可以create table tttt as select distinct * from yourTable ;
    delete from yourTable ;
    insert into yourTable select * from ttt;
    当您的问题得到解答后请及时结贴.
    http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
      

  5.   

    right , 我用的哦是 
    create table tttt as select distinct * from yourTable ; 
    delete from yourTable ; 。。
     
      

  6.   

    http://jeff1987.blog.51cto.com/910685/271142
      

  7.   

    http://jeff1987.blog.51cto.com/910685/271142