MySQL从列中删除尾随的换行符 [英] MySQL Removing trailing linebreaks from a column

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

问题描述

我想从我的MySQL列中删除尾随的换行符. trim()仅删除空格,但我也想删除尾随的换行符. 有人可以建议吗?

I want to remove trailing line breaks from my MySQL column. trim() only removes whitespaces but I also want to remove trailing linebreaks. Could anyone suggest?

推荐答案

您可以直接在SQL中替换它们,方法是在末尾匹配"\ r",然后替换该"\ r".

You can replace these directly from SQL by matching "\r" at the end, then replacing that "\r".

示例:

UPDATE Person SET firstName = REPLACE(firstName, '\n', '')
where firstName LIKE '%\n'

UPDATE Person SET firstName = REPLACE(firstName, '\r', '')
where firstName LIKE '%\r'

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

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