← Back to writing

TRIM Line Breaks & Carriage Return on MySQL

The TRIM() function on MySQL remove leading and trailing spaces. But what if you want to remove line break / carriage return?
Its not pretty, but this works for me:
REPLACE(FIELD_NAME, ’\r\n’,“)
Usage example:
Select FIELD_NAME 
From TABLE 
Where REPLACE(FIELD_NAME, ’\r\n’,”)=‘NOLINEBREAK’