Posterous

once upon a life

a life worth living

« Back to posts
  • Viewed
    times
September 13, 2011

TRIM Line Breaks & Carriage Return on MySQL

  • Edit
  • Delete
  • Tags
  • Autopost
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'
Tweet
  • 0 responses
  • Like
  • Comment