SMF Support > SMF 1.1.x Support

SQL query code need to move topics with specifc keyword

(1/1)

sharks:
Hello

I am using SMF 1.1.16 and i need help to mass move thousands of topics from a specific board to another board, based on the keyword that it contains inside the topic. So, i just need a query that i can run in phpMyAdmin, so that a search is done within all topics (includes all replies) to find "house" and then move all these topics to another board. I think that should be possible. Thanks for the help. :)

Runic:
just outta curiosity .... why?

Colin:
SELECT * FROM `smf_messages` WHERE body LIKE '%house%';

This will pull everything in the messages table, but you will need to then pull the data from the topics table as well if it is a new topic. You would need to have something in PHP for that.

Arantor:
Doesn't work like that, you need to first find all the topics that contain that word:

SELECT id_topic FROM smf_messages WHERE body LIKE '%house%' GROUP BY id_topic

Then you need to update both the topics and messages tables.

UPDATE smf_topics SET id_board = <new board's id> WHERE id_topic IN (the big list of topic ids here)

UPDATE smf_messages SET id_board = <new board's id> WHERE id_topic IN (the big list of topic ids here)

sharks:

--- Quote from: Runic on May 11, 2012, 03:14:53 PM ---just outta curiosity .... why?

--- End quote ---
I'm creating a new board to group all similar-themed topics.

Navigation

[0] Message Index

Go to full version