MySQL Removing trailing linebreaks from a column

后端 未结 6 2041
夕颜
夕颜 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:56

    Based on EternalHour's answer:

    UPDATE TABLE_NAME SET `COLUMN_NAME` = TRIM(TRIM(TRAILING '\r' FROM TRIM(TRAILING '\n' FROM TRIM(`COLUMN_NAME`))))
    

    this one removes trailing \r\n one by one, so either it is a newline or a carriage return or both, it will be stripped, and also removes whitespaces before and after the process.

提交回复
热议问题