wordpress 数据表操作:删除内容为空的文章,删除重复的文章,删除一定长度内容的文章

删除空数据,删除内容为空的文章:

DELETE FROM `wp_posts` WHERE  `post_content` =  “”

删除一定长度内容的文章:

DELETE FROM `wp_posts` WHERE LENGTH(post_content)<“2500”

删除重复的文章

1. 插件:使用一款插件,名字叫做Delete Duplicate Posts

2. 操作数据库:

CREATE TABLE my_tmp AS SELECT MIN(ID) AS col1 FROM wp_posts GROUP BY post_title;
DELETE FROM wp_posts WHERE ID NOT IN (SELECT col1 FROM my_tmp);
DROP TABLE my_tmp;

3.php程序删除

require('./wp-load.php');
$strsql="create table my_tmp as select min(ID) as col1 from cd_posts group by post_title";
$strsql1="delete from cd_posts where ID not in (select col1 from my_tmp)";
$strsql2="drop table my_tmp";
$result=mysql_query($strsql);
$result=mysql_query($strsql1);
$result=mysql_query($strsql2);

保存以上代码以为delete.php,放在根目录,例如,对于我的网站来说然后访问此文件

One Reply to “wordpress 数据表操作:删除内容为空的文章,删除重复的文章,删除一定长度内容的文章”

发表评论