Solved

Remove "new line"character

Posted on 2010-11-21
7
1,474 Views
Last Modified: 2012-08-13
Hi Guys,

I need a MySQL Syntax to remove "new line" character in a field.

I've tried these 2 code, but it not working

UPDATE table1 SET assigned_user_id=REPLACE(assigned_user_id, '\r\n', '');
UPDATE table1 SET assigned_user_id=REPLACE(assigned_user_id, '\n', '');

Please help. Thanks.
0
Comment
Question by:softbless
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 6

Expert Comment

by:DalHorinek
ID: 34182944
Maybe try

update table1 SET assigned_user_id = TRIM(TRAILING '\n' FROM assigned_user_id)
0
 

Author Comment

by:softbless
ID: 34182946
@DalHorinek it's still working

And i've also tried below, and it's also not working:
update table1 SET assigned_user_id = TRIM(TRAILING '\r\n' FROM assigned_user_id)
0
 

Author Comment

by:softbless
ID: 34182965
I mean it's still NOT working
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 6

Expert Comment

by:DalHorinek
ID: 34182975
Wat about something like UPDATE table1  SET assigned_user_id=TRIM(REPLACE(REPLACE(assigned_user_id, "\n", ""), "\t", ""));


Also try it with simple select

SELECT REPLACE(assigned_user_id, "\n", "") FROM table1

if it does anything
0
 
LVL 26

Expert Comment

by:Umesh
ID: 34182984
Try this...

UPDATE table_name SET column_name = REPLACE(column_name, CHAR(13), '');
0
 
LVL 26

Accepted Solution

by:
Umesh earned 500 total points
ID: 34182991
Actually the new lines are a combination of a new line and a carriage return, namely "\r\n". In this case, you will need CHAR(13) or CHAR(10) can do the trick

Pls backup your table before running any suggested queries..

UPDATE table_name SET column_name = REPLACE(column_name, CHAR(10), '');

or just

UPDATE table_name SET column_name = REPLACE(column_name, CHAR(13), '');
0
 

Author Closing Comment

by:softbless
ID: 34183011
Thanks!
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More Fun with XML and MySQL – Parsing Delimited String with a Single SQL Statement Are you ready for another of my SQL tidbits?  Hopefully so, as in this adventure, I will be covering a topic that comes up a lot which is parsing a comma (or other…
All XML, All the Time; More Fun MySQL Tidbits – Dynamically Generate XML via Stored Procedure in MySQL Extensible Markup Language (XML) and database systems, a marriage we are seeing more and more of.  So the topics of parsing and manipulating XM…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question