首页 > CMS > 帝国Empire > 正文

自动删除新闻模型重复数据 并保留最后一条 帝国CMS V7.0

2024-08-28 12:21:40
字体:
来源:转载
供稿:网友

delete phome_ecms_news from phome_ecms_news, (select id from phome_ecms_news group by title having count(*)>1 ) as t2 where phome_ecms_news.id=t2.id

执行完成以上命令,还要执行一下 下面的语句来修正 副表.

delete from 'phome_ecms_news_index' where id not in(select id from phome_ecms_news)//开源软件:Vevb.com

以上命令执行完即可,也可以用以下的命令修正副表 ID 错误,用以下命令进入 PHPMYADMIN 管理多于的错误 ID:

SELECT id FROM phome_ecms_news_data_1 WHERE NOT EXISTS (SELECT null FROM phome_ecms_news WHERE phome_ecms_news.id = phome_ecms_news_data_1.id);

 
 
 
 
 
解释:
delete 表 from 表, (select id from 表 group by 重复字段名 having count(*)>1 ) as t2 where 表.id=t2.id

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表