MyBB Community Forums

Full Version: Deleting Threads from range date (using sql query)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
I want to know a sql query to delete threads from specific forum, from a given date range, without effecting the total post count of users.

Like,
Suppose the forum section name is , Development(fid=145).
I want to delete all threads in that forum from date range 25-02-2010 to 25-02-2009
without affecting the post count of users, i.e., users post count shall not change even after deleting the posts.

What sql query shall i perform.
DELETE FROM `mybb_posts` WHERE `fid` = '145' AND `dateline` BETWEEN '1235541600' AND '1267077600';
DELETE FROM `mybb_threads` WHERE `fid` = '145' AND `dateline` BETWEEN '1235541600' AND '1267077600';

Backup your database first. Note that the forum counters will be out of sync, and the next time you recount the users' post counts, it'll recount the true value...
Hey,
Thanks alot for the reply Matt,

Will try this out today Smile

Can you also post a query to delete users based on last activity.

Suppose,
I wan't to delete all users, who haven't been active on forum since 25-02-2009 , and have post count <= 1.

Also, '1235541600' you used in query, = 06:00:00, 25-02-2009 , is there any specific reason to use 6 in time?
DELETE FROM `mybb_users` WHERE `lastactive` <= '1235541600' AND `postnum` = '0';

The extra 6 hours would probably just be due to time zones, I used 00:00 when I got the timestamp.
Thanks alot Matt.. those worked out without a hassale..
though i used LIMIT 1000 at the end to put breakage, as it was going beyond my vps limit.. Toungue

Mind taking a look at this Matt?

http://community.mybboard.net/thread-68787.html