Sunday, 25 January 2009

Mysql Remove Line Breaks

I've recently had line breaks added to some data i've imported. Here's how you remove line breaks at the beginning and end of a field in mysql;

update temp_table set fieldname=trim(both char(13) from fieldname)

The above is only if you are in windows. I believe you can also use the folowing for linux;

update temp_table set fieldname=trim(both '\n' from fieldname)

You should also be able to use reaplce usinng the char method, e.g.

update temp_table set fieldname=replace(fieldname, char(13), '-')

I've not tested it though - I hope this helps!

5 comments:

Anonymous said...

Thanks for sharing.

Regards,
Application for Vehicle

Anonymous said...

hi, thanks. this help me much...

Prowebb said...

This is correct


web design mumbai

Search Engine Placement said...

Great tutorial! It was very helpful!

Web Design Kuwait said...

thank you for sharing this information.