我现在有一张表(news),里面有几万条记录!但有些记录是重复的,比如说:字段title是重复的,但我现在想去掉这些重复的记录,不知道如何是好。

解决方案 »

  1.   

    如果存在不重复的字段ColAdelete a from news a where exists(select 1 from news where title=a.title and ColA<a.ColA)
      

  2.   

    select a.* from news a where exists(select 1 from news where title=a.title and ColA!=a.ColA)
      

  3.   

    记录行是完全相同怎么办??
    ----
    select col1,col2......
    from table 
    group by col1,col2....
    having count (1) > 0不是完全相同又怎么办???
    ---
    比如colN不同
    select * 
    from table a
    where not exists(select 1 from table where col = b.col and col1= b.col1 and colN > a.colN)
      

  4.   

    select * from news where title in
    (select title from 
    (select title,count(title) as CountTitle from test Group by title) Temptbl
    where CountTitle>1)
    可以查处Title重复的所有记录。
      

  5.   

    delete * from news where title in(select title form news a group by title having count(title)>1)