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

Thomas Owens picture Thomas Owens · Nov 11, 2008 · Viewed 49.6k times · Source

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.

Answer

David Hitchen picture David Hitchen · Mar 6, 2009

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',' ')