在 Mysql DB 中删除回车
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12903156/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Removing carriage returns in Mysql DB
提问by Jay Julian Payne
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:
在 phpmyadmin 我看到这个:
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?
有任何想法吗?
回答by LiamB
UPDATE xxxxxx set body = replace(body,'\r\n','');
UPDATE xxxxxx set body = replace(body,'\n','');
Try the above.
试试上面的。
回答by nads
Neither of these worked for me. Then I realized I also had paragraph breaks ?. This query worked for me:
这些都不适合我。然后我意识到我也有段落中断?。这个查询对我有用:
UPDATE xxxxxx SET body = REPLACE(REPLACE(body, '\r', ''), '\n', '');