View Full Version : sql query to remove all posts and replies
chikuru
12-30-2015, 12:11 PM
sql query to remove all posts and replies of a member?
Its not possible via web interface because it is timing out.
Number of posts to be removed are 100k+
Dragonsys
12-30-2015, 01:03 PM
DELETE FROM " . TABLE_PREFIX ."posts WHERE userid = YOUR_USER
If running from ACP,just change YOUR_USER to the userid you wish to remove.
If running from phpMyAdmin or such, change " . TABLE_PREFIX ." to the actual table prefix
chikuru
01-05-2016, 02:04 AM
Which should I rebuild after executing this?
The threads are still showing in forumdisplay and says invalid thread specified when clicked
Dragonsys
01-05-2016, 02:06 AM
Post counts and search index
chikuru
01-12-2016, 12:12 PM
Post counts and search index
I rebuilt both Post Counts and Search Index after running that query but the deleted posts still showing in forumhome and forumdisplay.. :confused:
Have you tried "Rebuild Thread Information" and "Rebuild Forum Information"?
chikuru
01-12-2016, 12:51 PM
Have you tried "Rebuild Thread Information" and "Rebuild Forum Information"?
Tried that but didnt help..
You have other suggestion Dave?
Wait so you executed the following query right? DELETE FROM posts WHERE userid = YOUR_USER
Since in vBulletin threads have a one to many relation to posts, it means that if the user started a thread, it will cause this problem because there's no post bound to it anymore.
You also have to execute a query such as:
DELETE FROM thread WHERE postuserid = USERID_OF_USER
chikuru
01-12-2016, 01:29 PM
Wait so you executed the following query right? DELETE FROM posts WHERE userid = YOUR_USER
Since in vBulletin threads have a one to many relation to posts, it means that if the user started a thread, it will cause this problem because there's no post bound to it anymore.
You also have to execute a query such as:
DELETE FROM thread WHERE postuserid = USERID_OF_USER
the 2nd query did it. Then rebuilt threads and forums. It worked!
Thanks for your great help Dave! As well as Dragonsys for always helping the vb community :up:
Dragonsys
01-12-2016, 01:42 PM
Wait so you executed the following query right? DELETE FROM posts WHERE userid = YOUR_USER
Since in vBulletin threads have a one to many relation to posts, it means that if the user started a thread, it will cause this problem because there's no post bound to it anymore.
You also have to execute a query such as:
DELETE FROM thread WHERE postuserid = USERID_OF_USER
Thanks Dave, I forgot that one.
squidsk
01-12-2016, 02:05 PM
And since the thread likely had posts not by the user you're removing deleting posts for you now have orphaned posts (i.e. posts not attached to an existing thread).
To delete them run the following:
DELETE FROM post WHERE NOT threadid IN (SELECT threadid FROM thread)
Note: this will remove all posts that are not associated with a thread, not just the ones related to threads you have just deleted.
chikuru
01-12-2016, 02:09 PM
Great! Thanks for the addition squidsk!
Im sure this thread will also help other forum owners who deletes thousands of spams in one go.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.