[Question] MySQL Search and Replace using PHPMyAdmin

Discussion in 'MySQL' started by Divvy, Oct 21, 2009.

  1. #1
    Hello friends,

    Maybe someone can help me with this...
    I need to replace a long text that I have in about 10.000 posts in my site.
    But I don't know If I can use the REPLACE query to do that.
    I use that query to replace some words, or little things, but never long texts. It is possible? I tried but didn't work. Maybe I am doing something wrong...

    This is the query that I'm using:
    UPDATE table_name set table_field = REPLACE (table_field, ‘replace_that’, ‘with_this’);
    Code (markup):
    The problem is the text have breaklines, html codes, etc...
    Take a look of an text example:

    This is the query that I tried:
    UPDATE wp_posts SET post_content = REPLACE (post_content,'<strong>TEXT TITLE</strong>
    <span style="font-weight: bold; color: #0000FF;">xxxxxxxxxxxxxxxxxxx:
    - yyyyyyyyyyyyyyyy 
    - yyyyyyyyyyyyyyyy 
    - yyyyyyyyyyyyyyyy 
    - yyyyyyyyyyyyyyyy 
    
    <span style="font-weight: bold; color: #0000FF;">xxxxxxxxxxxxxxxxxxx 2:
    1- yyyyyyyyyyyyyyyy 
    2- yyyyyyyyyyyyyyyy 
    3- yyyyyyyyyyyyyyyy 
    4- yyyyyyyyyyyyyyyy </span>','coming...')
    Code (markup):
    Can someone help me?
    Thank you
     
    Divvy, Oct 21, 2009 IP
  2. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #2
    I would suggest you to take help of php here.

    Write a small script which reads data from table, replaces the text and updates back the row.

    This can be done using MYSQL as well, but its safer to do with php as you can do much debug and better replace there.
     
    mastermunj, Oct 21, 2009 IP
  3. Divvy

    Divvy Well-Known Member

    Messages:
    785
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #3
    hi,

    thank you for your reply!
    But I already solve my problem. :)
     
    Divvy, Oct 22, 2009 IP