[英]MySQL: how to replace literal \r\n with special characters \r\n
I have some faulty PHP code which inserted literal \\r\\n characters into the database instead of the special characters representing new line and carriage return. 我有一些错误的PHP代码,它在数据库中插入了文字\\ r \\ n字符,而不是代表换行符和回车符的特殊字符。 Can anyone help me come up with a query that will replace the literals with the special characters?
谁能帮我提出一个查询,用特殊字符替换文字?
Here's an SQL Fiddle setup. 这是一个SQL Fiddle设置。 All I really need is something that will return the row containing "abc\\r\\ndef" rather than the other row.
我真正需要的是将返回包含“ abc \\ r \\ ndef”的行而不是另一行的东西。 It's probably a very simple escape that's needed, but I can't work it out.
这可能是需要的非常简单的转义,但我无法解决。
http://sqlfiddle.com/#!9/1f2acb/1 http://sqlfiddle.com/#!9/1f2acb/1
Once I have that query I guess I will simply use 一旦有了该查询,我想我只会使用
UPDATE test SET txt replace(txt, 'UNKNOWN EXPRESSIOn', '\\r\\n'); UPDATE test SET txt replace(txt,'UNKNOWN EXPRESSIOn','\\ r \\ n');
I'm running MySQL 5.5 on Ubuntu. 我在Ubuntu上运行MySQL 5.5。
答案是一个与juanvan相关的类似问题。
UPDATE test set txt = replace(txt,'\\r\\n','\r\n');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.