Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing carriage returns in Mysql DB

Tags:

I'm trying to replace junk in my DB:

UPDATE xxxxxx set body = replace(body,'<p></p><p>','<p>')

Some tags are not getting replaced because there are line breaks between them...

In phpmyadmin I see this:

yadda yadda<p></p>
<p>yadda yadda

This didn't work..

UPDATE xxxxxx set body = replace(body,'\\r\\n','');
UPDATE xxxxxx set body = replace(body,'\\r','');
UPDATE xxxxxx set body = replace(body,'\\r','');

WHERE ARE THE BREAKS COMING FROM??

Any ideas?

like image 464
Jay Julian Payne Avatar asked Oct 15 '12 20:10

Jay Julian Payne


People also ask

How to remove carriage return and line feed in sql?

Remove and Replace Carriage Returns and Line Breaks in SQL Using SQL to remove a line feed or carriage return means using the CHAR function. A line feed is CHAR(10); a carriage return is CHAR(13).

How to remove next line in MySQL?

The Trim() function is used to remove new line characters from data rows in MySQL.

How do I remove a character from a column in MySQL?

Remove characters from string using TRIM() Name of the table. Name of the column whose values are to be updated. The characters to be removed from each value. BOTH: used when we want to remove characters from beginning and end.


1 Answers

UPDATE xxxxxx set body = replace(body,'\r\n','');
UPDATE xxxxxx set body = replace(body,'\n','');

Try the above.

like image 67
LiamB Avatar answered Mar 01 '23 15:03

LiamB