MySQL Removing trailing linebreaks from a column

后端 未结 6 2079
夕颜
夕颜 2021-01-05 15:29

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?

6条回答
  •  感动是毒
    2021-01-05 15:47

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

    Example:

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

    or

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

提交回复
热议问题