分两段代码分别执行,第一段是删除多余重复标题,第二段是跟随内容删除多余的TAG标签,两个SQL命令需要分别执行。
DELETE FROM le_cms_article WHERE title IN ( SELECT a.title FROM ( SELECT title FROM le_cms_article GROUP BY title HAVING count( title ) > 1 ) a ) AND id NOT IN ( SELECT b.id FROM ( SELECT id FROM le_cms_article GROUP BY title HAVING count( title ) > 1 ) b )
delete from le_cms_article_data where not exists (select * from le_cms_article where le_cms_article_data.id =le_cms_article.id);
以下是分开的版本: 先执行这个: DELETE FROM le_cms_article WHERE title IN ( SELECT a.title FROM ( SELECT title FROM le_cms_article GROUP BY title HAVING count( title ) > 1 ) a ) AND id NOT IN ( SELECT b.id FROM ( SELECT id FROM le_cms_article GROUP BY title HAVING count( title ) > 1 ) b ) 再执行这个: delete from le_cms_article_data where not exists (select * from le_cms_article where le_cms_article_data.id =le_cms_article.id); 来源:
声明:本站所有内容/本文内容/及图片/由互联网用户投稿自发贡献,该文观点仅代表其作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭/侵权/违法违规的内容, 请发送邮件至 123456@qq.com 举报,一经查实,本站将立刻删除。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。