Hi!
What SQL query should I run to the database to delete posts in specific forums? The control panel freezes due to the large number of posts.
DELETE FROM `wpforo_posts`
WHERE `topicid` IN (
SELECT `topicid` FROM (
SELECT `topicid` FROM `wpforo_topics` WHERE `forumid` IN (1, 2, 3)
) AS temp_table
);
DELETE FROM `wpforo_topics`
WHERE `forumid` IN (1, 2, 3);
DELETE FROM `wpforo_forums`
WHERE `forumid` IN (1, 2, 3);
Can I use this one?
Hi vasiliy,
Running a direct SQL query is a solid approach to handle bulk deletions efficiently. Here's a query structure that should work well for your situation:
DELETE FROM `wpforo_posts` WHERE `topicid` IN ( SELECT `topicid` FROM ( SELECT `topicid` FROM `wpforo_topics` WHERE `forumid` IN (1, 2, 3) ) AS temp_table ); DELETE FROM `wpforo_topics` WHERE `forumid` IN (1, 2, 3);
This approach works in stages: first, it deletes all posts from the specified forums (identified by their forum IDs), and then it deletes the topics themselves.
IMPORTANT:
The key thing here is to replace the forum IDs (1, 2, 3 in two places) with the actual IDs of the forums where you want to delete posts. You can adjust the IN clause to include as many or as few forum IDs as needed.
Safety Tip: Before running this query on your live database, I'd strongly recommend backing up your database first. Direct SQL queries can't be undone, so having a backup gives you peace of mind. Also, consider testing the query on a staging environment if you have one available.
Once you've identified the correct forum IDs and backed up your data, you can run this through your database management tool (like phpMyAdmin or your hosting provider's database interface). This should be much faster than using the control panel.