Moving all threads within a category to a new location

JVCode

Well-known member
Okay, I'm trying to move several thousand threads to a new location from within a category, why am I not just moving them from within the forums? because there's around 1,100 forums within 25 different categories. Is there a way I can do this? either by using the node tree, or even going in via phpmyadmin.

EDIT: 1 Category, 25 forums, several hundred sub-forums.

Thanks!
 
Run this query:
Code:
UPDATE xf_thread
SET node_id = y
WHERE node_id = x

Where x is the current node ID and y is the new node ID.

That will move all threads from one forum to another.

Thanks, already given this method a shot and is doesn't work for my scenario. I have one main forum with around 50 sub-forums attached to it, is there a query where I can say "Okay, move all thread from within the main forum (including all threads from sub-forums) to a new forum."
 
No, each node has a node ID.
You will need to to do them all individually.

It doesn't take long to prepare and run queries, just copy and paste and change the source node ID.
 
Yes, just terminate each line with a ;

So for example:
Code:
UPDATE xf_thread SET node_id = y WHERE node_id = x;
UPDATE xf_thread SET node_id = y WHERE node_id = x;
UPDATE xf_thread SET node_id = y WHERE node_id = x;
UPDATE xf_thread SET node_id = y WHERE node_id = x;
UPDATE xf_thread SET node_id = y WHERE node_id = x;
UPDATE xf_thread SET node_id = y WHERE node_id = x;
 
there's around 1,100 forums within 25 different categories

I think you need this query:

Rich (BB code):
UPDATE xf_thread AS t
SET t.node_id = X
WHERE t.node_id IN (
	SELECT n.node_id
	FROM xf_node AS n
	WHERE n.lft BETWEEN Y AND Z
);

X is the destination node_id.

Y AND Z are the nested set boundaries for the category which you can see in the xf_node table:

Screen shot 2012-03-21 at 3.20.55 AM.webp

This query will move every thread from every forum underneath that category if you specify the nested set bounds of the category.

Backup first.
 
Top Bottom