View Full Version : SQL query to find/repalce post text in a specific forum
anjaan7979
10-29-2011, 04:56 PM
Hello,
I am trying use a sql query to find and replace a certain word in a specific forum.
I tried the following but that did not work.
UPDATE post SET pagetext = REPLACE(pagetext, 'oldtext', 'newtext') WHERE forumid='435'
Here is the error:
An error occurred while attempting to execute your query. The following information was returned.
error number: 1054
error desc: Unknown column 'forumid' in 'where clause'
Any help is appreciated. Thank you.
Lynne
10-29-2011, 07:29 PM
Well, as the error says, there is no forumid column in the post table. You would need to join with the thread table (post.threadid = thread.threadid) in order to get the forumid (thread.forumid).
vbresults
10-29-2011, 08:18 PM
Well, as the error says, there is no forumid column in the post table. You would need to join with the thread table (post.threadid = thread.threadid) in order to get the forumid (thread.forumid).
UPDATE post
SET pagetext = REPLACE(pagetext, 'oldtext', 'newtext')
WHERE (SELECT forumid FROM thread WHERE thread.threadid = post.threadid) = 435
anjaan7979
10-30-2011, 05:29 AM
UPDATE post
SET pagetext = REPLACE(pagetext, 'oldtext', 'newtext')
WHERE (SELECT forumid FROM thread WHERE thread.threadid = post.threadid) = 435
That worked like a charm! Thanks a lot.
Some questions:
1. What if I want to replace multiple words?
2. For multiple Child forums, is it possible to select a parent forum?
This will cut down a lot of time for me.
Thanks again.
vbresults
11-03-2011, 06:23 PM
UPDATE post
SET pagetext = REPLACE(pagetext, 'oldtext', 'newtext')
WHERE (SELECT forumid FROM thread WHERE thread.threadid = post.threadid) = (SELECT forumid FROM forum WHERE parentid = 435)
Where 435 can be swapped out for another 'parent' forum.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.