写SQL:有一个表主键T1为自动增长,其他字段为T2、T3、T4,删除主键之外其他字段数据完全相同的脏数据。

解决方案 »

  1.   

    select t2,t3,t4 from 表
    group by t2,t3,t4
    having count(*)>1
      

  2.   

    LZ的意思是,T2-T4只要重复的数据都删掉?不用管T1?
      

  3.   

    delete
    from T
    where T2=T3 and T3=T4
      

  4.   

    首先要弄清楚什么是脏数据,即便一条记录中T2=T3=T4也并不一定是脏数据。脏数据就是指除主键以外其他字段与另外的某写记录的字段值完全相同的重复的记录。
      

  5.   

    建一个临时表
    按照
    select t2,t3,t4 from 表
    group by t2,t3,t4
    having count(*)〉=2
    找到所有你所谓的脏数据。
    插入临时表
    用delete 表
    group by t2,t3,t4
    having count(*)〉=2
    删除这些记录。
    然后再把临时表里的数据插回来
      

  6.   

    试试这个delete 表 where t1 not in ( select min(t1)  from 表 group by t2, t3, t4 )
      

  7.   

    delete from Table where T2=T3 and T3=T4
      

  8.   

    delete from Table where T2=T3 and T3=T4
    ---------------------------------------
    这可是最简单的删除呀!!LZ,还有什么不明白的?
      

  9.   

    t1 t2 t3 t4 
    1  2  2  2
    2  3  4  5
    3  3  4  5
    t1=1的不是脏数据。
    t1=2和t1=3的才是脏数据。楼主是这意思把?
      

  10.   

    delete from ttt group by t2+t3+t4 having sum(t2+t3+t4)>t2+t3+t4
      

  11.   

    delete from Table where T2=T3 and T3=T4
    这是正解。