Does the MySQL TRIM function not trim line breaks or carriage returns?

后端 未结 10 1764
旧时难觅i
旧时难觅i 2020-12-03 13:58

From my experiments, it does not appear to do so. If this is indeed true, what is the best method for removing line breaks? I\'m currently experimenting with the parameters

相关标签:
10条回答
  • 2020-12-03 14:18

    The answers above, when combined, work. A full example of replacing linebreaks at the beginning and end of the field looks like this:

    UPDATE table SET field=REPLACE(field, field, TRIM(BOTH '\r\n' FROM field))
    
    0 讨论(0)
  • 2020-12-03 14:20

    My line breaks were in the middle of the string, and I didn't have control over the source data. The following mysql command worked for me:

    REPLACE(FIELD,'\r\n',' ')
    
    0 讨论(0)
  • 2020-12-03 14:21

    REPLACE(FIELD,'\r\n',' ') works perfectly on MySql 5.1 database

    0 讨论(0)
  • 2020-12-03 14:22

    select trim(both '\r\n' from FIELDNAME) from TABLE; should work if select trim(both '\n' from FIELDNAME) from TABLE; doesn't work.

    0 讨论(0)
提交回复
热议问题