delete from table1 where a not in(select min(a) from table group by b)

解决方案 »

  1.   

    可以考虑用一个临时表来过渡吧?并且我觉得用一句SQL语句实现可能有困难,大概需要几条语句吧?
      

  2.   

    table1(a,b)
    a   b 
    1   10
    2   20 
    3   30
    4   10
    5   10
    删除有重复字段内容的记录,只保留一条。
    delete from table1
    where goodid not in (select max(goodid) from table1 group by goodin)
    删除所有有重复字段内容的记录。
    select * from table1
    delete from table1 where goodin in (select  goodin from table1
    group by goodin
    having count(*)>1)
    删除所有不重复字段内容的记录。
    delete from table1 where goodin in (select goodin from table1 group by goodin having count(*) < 2)
       
      

  3.   

    上面表字段a,b 改为goodid,goodin
      

  4.   

    删除所有有重复字段内容的记录。
    delete from table1 where goodin in (select  goodin from table1
    group by goodin
    having count(*)>1)