How to find line break and carriage return (\r\n) in MySQL - MySQL Tutorial

How to find line break and carriage return (\r\n) in MySQL

You are working as MySQL Developer and you need to write a query that should return all the values from column which has carriage return or line break or both of them.

Let's create sample test table with some sample data and then write the query to get the records with line break and carriage return (\r\n).


create table test(id int, name varchar(100));

-- insert some sample data
insert into test 
values(1,'Aamir\n'),
(2,'shahzad'),
(3,'Robert\r\n'),
(4, 'This is \n test'); 



Below query will return all the values which has \n or \r or both of them.

select * from test;
SELECT * FROM test WHERE
name like '%\n%'
or name like '%\r\n%';


How to find records with line break and carriage return in MySQL - MySQL Tutorial

2 comments:

  1. It CGBSE Textbook 2023 is very important for every students. This year it examination was conducted from February, March, Examination was held on various examination centers in all over Chhattisgarh state. Board will CG Board 9th Book 2023 announce CG Board 9th class exam Textbook 2023 on CGBSE 9th Textbook 2023 site cgbse.net in May and June month. The CG Board official site Chhattisgarh Board 9th Textbook 2023

    ReplyDelete