简体   繁体   中英

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. Can anyone help me come up with a query that will replace the literals with the special characters?

Here's an SQL Fiddle setup. All I really need is something that will return the row containing "abc\\r\\ndef" rather than the other row. It's probably a very simple escape that's needed, but I can't work it out.

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');

I'm running MySQL 5.5 on Ubuntu.

答案是一个与juanvan相关的类似问题。

UPDATE test set txt = replace(txt,'\\r\\n','\r\n');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM