MySQL输出中的换行符 [英] Escape line breaks in MySQL output

查看:103
本文介绍了MySQL输出中的换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一列想要检查的列,其中包含带换行符的字符串.我希望能够显式查看这些字符串中的\n\r字符.有什么方法可以编写我的SQL查询,以告诉它输出带有换行符的字符串?

I have a a column I want to inspect that contains strings with newlines in them. I want to be able to explicitly see the \n and \r characters that are in these strings. Is there some way to write my SQL query to tell it to output the strings with the newlines escaped?

推荐答案

SELECT REPLACE(
    REPLACE(yourcolumn, '\r', '\\r'),
    '\n',
    '\\n'
) FROM yourtable;

这篇关于MySQL输出中的换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆