Question

I'm needing to cleanup our database and need to mass replace something like this:

<div class="rtecenter"><br />
<font color="#990033"><strong>I'm so hot, I sometimes spontaneously combust.</strong></font><br />
<img src="http://i476.photobucket.com/albums/rr124/phoenix_oasis/coollogo_com_63811610.gif" alt="" /></div>

(I'm simply going to remove all instances of it). I already know how to do a mass replace (I'm using PHPMyAdmin), however The problem is that it has CR/LF's in it so I'm not sure how to add the correct string to find in the query ... just for testing, I've tried doing searches using Char(10) or Char(13) where the new lines are but no results are ever returned, (I know they are there though).

Anyone know?

Was it helpful?

Solution

If there are only CR/LF's, then you can use this query -

UPDATE table
SET
  column = REPLACE(column, '<div class="rtecenter"><br />\r\n<font color="#990033"><strong>I''m so hot, I sometimes spontaneously combust.</strong></font><br />\r\n<img src="http://i476.photobucket.com/albums/rr124/phoenix_oasis/coollogo_com_63811610.gif" alt="" /></div>', '');

If there are different line separators, then you can do it in two steps:

UPDATE table
SET
  column = REPLACE(column, '\r', ''); -- replace all \r\n to \n

UPDATE table
SET
  column = REPLACE(column, '<div class="rtecenter"><br />\n<font color="#990033"><strong>I''m so hot, I sometimes spontaneously combust.</strong></font><br />\n<img src="http://i476.photobucket.com/albums/rr124/phoenix_oasis/coollogo_com_63811610.gif" alt="" /></div>', '');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top