Search code examples
mysqlstringtrim

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


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 that TRIM accepts of the character to remove, starting with trimming \n and \r.


Solution

  • Trim() in MySQL only removes spaces.

    I don't believe there is a built-in way to remove all kinds of trailing and leading whitespace in MySQL, unless you repeatedly use Trim().

    I suggest you use another language to clean up your current data and simply make sure your inputs are sanitized from now on.