Find/Replace text in content body

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cewyattjr@gmail.com

    Find/Replace text in content body

    In a mediumtext field I have many instances of a URL, eg:
    'http://myurl.com/index.php' that I want to replace with just '/'

    How can I write an update query that will update all instances of the
    URL in all records with this field?

    eg:

    select id, fulltext from content LIKE '%http://myurl.com/index.php%'

    But THEN what? I'm working with phpmyadmin, but I guess I could just
    write this as a PHP script as well? Probably easier to just inject SQL
    using the utility program, tho', eh?

    Thanks!

    -CW

  • milahu

    #2
    Re: Find/Replace text in content body

    Found this suspicious replace function far [1] away from official mysql
    site:

    update [table_name]
    set [field_name] = replace(
    [field_name],
    '[string_to_find]',
    '[string_to_repla ce]'
    );

    dunno if this one really works...

    [1] http://www.nikmakris.com/2005/mar/29.html

    Comment

    • cewyattjr@gmail.com

      #3
      Re: Find/Replace text in content body

      Works GREAT!

      Comment

      Working...