Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    183
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Replacing a string segment inside a TEXT field

    I've got a table with about 50 entries of text in it. But, those entries use <br /> instead of \r\n so when I output them they go straight into the right format. However, I'd like to replace all instances of <br /> in my table with "\r\n" and then use nl2br() when I output them.

    How would my query look?

    Thanks for any help
    Offtone.com - In the works...

  • #2
    New Coder
    Join Date
    Jun 2002
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Replacing a string segment inside a TEXT field

    As far as I am aware it is not possible to replace part of a field with a single query.

    What you will have to either make the changes manually or write a small script to read in each record, make the change and then update the database with the updated data.
    ----------------------------------------------
    http://www.laughland.biz
    "the web site for web sites"
    (don't forget to cast your diamond web award vote while on site!)
    -----------------------------------------------

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    There is a REPLACE() function that should do exactly what you ask for:
    http://www.mysql.com/doc/en/String_f...s.html#IDX1186

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    183
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Excellent Thanks all.
    Offtone.com - In the works...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •