View Full Version : Replacing a string segment inside a TEXT field
SYP}{ER
11-02-2002, 02:01 PM
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 :)
laughbiz
11-03-2002, 01:16 AM
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.
mordred
11-03-2002, 10:26 AM
There is a REPLACE() function that should do exactly what you ask for:
http://www.mysql.com/doc/en/String_functions.html#IDX1186
SYP}{ER
11-04-2002, 08:54 PM
Excellent :) Thanks all.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.