现有一表article有如下字段tid, subject, content, ontime
其中有不少重复subject的记录现在要查询subject重复的记录!

解决方案 »

  1.   

    select tid, subject from article group by subject having count(subject) > 1
      

  2.   

    select * from article a where exists (select 1 from article where subject=a.subject and tid!=a.tid);
      

  3.   

    我试试,不过,有group by 和having是不是很慢啊,我这个有500w多的数据
      

  4.   

    SELECT A.* FROM TT A INNER JOIN
    (SELECT subject FROM TT GROUP BY subject HAVING COUNT(*)>=2) B
    ON A.subject=B.subject