- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What would be a query to remove nn from the text in MySQL?
To remove
\r from the text, you need to use REPLACE command. The syntax is as follows −
UPDATE yourTableName SET yourColumnName=REPLACE(yourColumnName,’\r
’,’ ‘);
To understand the above syntax, let us create a table. The query to create a table is as follows −
mysql> create table removeDemo -> ( -> Id int NOT NULL AUTO_INCREMENT, -> Name text, -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.79 sec)
Now insert some records in the table using insert command. The query is as follows −
mysql> insert into removeDemo(Name) values('John\r
SmithCarol'); Query OK, 1 row affected (0.13 sec) mysql> insert into removeDemo(Name) values('LarryMike\r
Sam'); Query OK, 1 row affected (0.34 sec) mysql> insert into removeDemo(Name) values('David\r
BobJames'); Query OK, 1 row affected (0.10 sec)
Display all records from the table using select statement. The query is as follows −
mysql> select *from removeDemo;
The following is the output in a format that includes \r
, therefore the output isn’t looking properly formatted −
+----+------------------+ | Id | Name | +----+------------------+ | 1 | John SmithCarol | | 2 | LarryMike Sam | | 3 | David BobJames | +----+------------------+ 3 rows in set (0.00 sec)
Here is the query to remove \r
from text −
mysql> update removeDemo set Name=replace(Name,'\r
',''); Query OK, 3 rows affected (0.12 sec) Rows matched: 3 Changed: 3 Warnings: 0
Now check the table records once again. The query is as follows −
mysql> select *from removeDemo;
The following is the output −
+----+----------------+ | Id | Name | +----+----------------+ | 1 | JohnSmithCarol | | 2 | LarryMikeSam | | 3 | DavidBobJames | +----+----------------+ 3 rows in set (0.00 sec)
- Related Articles
- What would be a query to remove from the text in MySQL?
- MySQL query to remove text between square brackets?
- MySQL query to select bottom n records
- MySQL query to select top n rows efficiently?
- C# program to remove n-th character from a string
- JavaScript - Remove first n characters from string
- How to remove partial text from value in MySQL?
- MySQL query to sort increasing the difference between n and the value in the table?
- MySQL query to remove special characters from column values?
- How to get first N characters from a MySQL column?
- How to remove only the first word from columns values with a MySQL query?
- MongoDB query to skip n first documents?
- Program to create a list with n elements from 1 to n in Python
- MySQL query to remove Null Records in a column?
- If the sliding friction betwen two surfaces is found to be 8 N, then the static friction between these two surfaces is most likely to be:(a) 5 N(b) 10 N(c) 4 N(d) 2 N
- Remove decimal from records and sum them using a MySQL query

Advertisements