自己亲测好用的! 感谢群友 go9go的帮助
多数据表用以下的sql语句
INSERT INTO phome_ecms_news_check SELECT * FROM phome_ecms_news; delete from phome_ecms_news; INSERT INTO phome_ecms_news_check_data SELECT * FROM phome_ecms_news_data_1; INSERT INTO phome_ecms_news_check_data SELECT * FROM phome_ecms_news_data_2; INSERT INTO phome_ecms_news_check_data SELECT * FROM phome_ecms_news_data_3; delete from phome_ecms_news_data_1; delete from phome_ecms_news_data_2; delete from phome_ecms_news_data_3; update `phome_ecms_news_index` set `checked`=0;
单表数据的用以下的sql语句
INSERT INTO phome_ecms_news_check SELECT * FROM phome_ecms_news; delete from phome_ecms_news; INSERT INTO phome_ecms_news_check_data SELECT * FROM phome_ecms_news_data_1; delete from phome_ecms_news_data_1; update `phome_ecms_news_index` set `checked`=0;
处理 重复的保留一个有用 清除另外出错没有用
delete from phome_ecms_news_check where not exists (select * from phome_ecms_news_check_data where phome_ecms_news_check.id = phome_ecms_news_check_data.id); delete from phome_ecms_news_check_data where not exists (select * from phome_ecms_news_check where phome_ecms_news_check_data.id = phome_ecms_news_check.id); delete from phome_ecms_news where exists (select * from phome_ecms_news_check where phome_ecms_news_check.id = phome_ecms_news.id);