mysql replace

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marcus

    #1

    mysql replace

    Hi

    I have a large database with text strings.

    What is the quickest way to replace each ['] with a ['] throughout
    the database fields while leaving everything else intact?

    ex

    .... I'm a monkey ...

    becomes

    .... I'm a monkey ...

    etc

    Thanks!
  • Wouter

    #2
    Re: mysql replace

    <snip>What is the quickest way to replace each ['] with a [&#39;]</snip>
    <off topic>
    Maybe you also want to look at this place:


    For other characters you want to replace
    </off topic>

    Sorry, can't help you with the MySQL thing, I also don't know what the
    fastest way is to replace all.

    Ciao,
    Wouter


    Comment

    • Bill Karwin

      #3
      Re: mysql replace

      Marcus wrote:[color=blue]
      > What is the quickest way to replace each ['] with a [&#39;] throughout
      > the database fields while leaving everything else intact?[/color]

      I'd try this:

      UPDATE myTable SET
      textField1 = REPLACE(textFie ld1, '\'', '&#39;'),
      textField2 = REPLACE(textFie ld2, '\'', '&#39;'),
      textField3 = REPLACE(textFie ld3, '\'', '&#39;');

      You probably have to repeat this for every table that contains text fields.

      See http://dev.mysql.com/doc/mysql/en/String_functions.html for more
      info on REPLACE() and many other string functions built into MySQL.

      MySQL has a pretty good set of builtin functions, and familiarizing
      yourself with them is a worthwhile thing to do if you use MySQL regularly.

      Regards,
      Bill K.

      Comment

      Working...