wp_posts 表中的post_title字段中存在重复记录,我删除所有这些重复记录,只要是存在重复,该记录和重复记录全部删除,不知道用mysql如何操作比如:第1条和第5条记录中post_title中内容相同,那么就删除第1条和第5条。谢谢!

解决方案 »

  1.   


    字段            类型ID            bigint(20)      
    post_title    text 
    post_content  longtext 重复记录例如:
    ID           post_title               post_content
    44           无线网安全隐患解决之道      46           无线网安全隐患解决之道...121          无线网安全隐患解决之道
      

  2.   

    将重复的全部去掉:
    select a.* from tt a left join
    (select post_title from tt group by post_title having count(*)>=2) b
    on a.post_title=b.post_title where b.post_title is null
      

  3.   

    我的要求是,将这些重复的记录全部删除,本身也不要,也就是44,46...121这样。原因:原来的网站CMS系统将分页全部作为两条记录处理,现在我在新CMS系统中导入时就出现了两个标题相同,但文章内容不同的文章,我需要将所有村里有相同记录的内容都删除!
      

  4.   

    自己学会举一反三
    delete a.* from tt2 a left join
    (select post_title from tt2 tt2group by post_title having count(*)>=2) b
    on a.post_title=b.post_title where b.post_title is not null
      

  5.   

    这个是查询没有重复的记录
    删除是下面一个SQL语句,在MYSQL5.1。37下测试没有问题,结果正确
      

  6.   

    这样不行吗?
    delete from aa where post_title in (select post_title from aa group by post_title having count(*)>=2)
      

  7.   

    delete from yourTable a
    where exists (select id from yourTable where post_title=a.post_title and ID<a.ID);
      

  8.   

    in、exists效率低,连接是最快的方法
      

  9.   

    MySQL 中 delete从表中的语法不是 delete from table1 [xxx] join table2 on .....
    建议参考 MySQL手册。DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
        FROM tbl_name[.*] [, tbl_name[.*] ...]
        USING table_references
        [WHERE where_definition]
      

  10.   

    呵呵,测试过我的代码没有?在MYSQL5.1。37下测试没有问题
      

  11.   

     原来是两个人:wwwwa和wwwwb,我一直看成一个人了