Solved

Remove "new line"character

Posted on 2010-11-21
7
1,469 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
  • 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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:ushastry
ID: 34182984
Try this...

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

Accepted Solution

by:
ushastry 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
Creating and Managing Databases with phpMyAdmin in cPanel.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now