vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   SQL query to find/repalce post text in a specific forum (https://vborg.vbsupport.ru/showthread.php?t=273029)

anjaan7979 10-29-2011 03:56 PM

SQL query to find/repalce post text in a specific forum
 
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.

Code:

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 06: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 07:18 PM

Quote:

Originally Posted by Lynne (Post 2262754)
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).

Code:

UPDATE post
        SET pagetext = REPLACE(pagetext, 'oldtext', 'newtext')
                WHERE (SELECT forumid FROM thread WHERE thread.threadid = post.threadid) = 435


anjaan7979 10-30-2011 04:29 AM

Quote:

Originally Posted by Lancerforhire (Post 2262763)
Code:

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 05:23 PM

Code:

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.


All times are GMT. The time now is 03:35 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02465 seconds
  • Memory Usage 1,718KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete