Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What would be a sql query to remove \n\r from the text?

Tags:

sql

mysql

I am using MySQL. My data has a column called text, which uses the TEXT data type.

There are several newlines for each record in this column. I want to remove all new lines with a sql query. How can I do that?

like image 582
user482594 Avatar asked Apr 29 '11 05:04

user482594


People also ask

How remove enter from text in SQL?

Char(13) is the carriage return and char(10) is the line feed symbol. How to remove line feed from a SQL Server column? To remove the carriage return or line feed directly from a SQL column, simply apply a replace method to remove it and replace with a space or an empty string.

How do I remove special characters from a number in SQL?

You can remove special characters from a database field using REPLACE() function.

What is N in SQL query?

The "N" prefix stands for National Language in the SQL-92 standard, and is used for representing Unicode characters. In the current standard, it must be an upper case , which is what you will typically find implemented in mainstream products.

How do you select nth value in SQL?

SELECT * FROM Employee; Now let's display the Nth record of the table. Syntax : SELECT * FROM <table_name> LIMIT N-1,1; Here N refers to the row which is to be retrieved.


1 Answers

Try this one -

CREATE TABLE table1(column1 TEXT);
INSERT INTO table1 VALUES ('text1\r\ntext2
text3');

SELECT * FROM table1;
--------
text1
text2
text3

UPDATE table1 SET column1 = REPLACE(column1, '\r\n', '');
SELECT * FROM table1;
--------
text1text2text3
like image 91
Devart Avatar answered Oct 05 '22 23:10

Devart