Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search text containing a new line in MySQL

Tags:

mysql

I have a MySQL table that stores a large number of products. By some mistakes i added some of the product name with a new line. I need to find them. The bellow query is not listing all of the expected data.

SELECT * FROM `products` WHERE `product_name` REGEXP "\r\n";
like image 862
Shijin TR Avatar asked Nov 24 '25 10:11

Shijin TR


1 Answers

It depend of way what you use to new line. Different text editor programs use different way to write new line.

Try to use only "\n" or combinations of "\r" and "\n".

For me worked this:

  SELECT * FROM `products` WHERE `product_name` REGEXP "\n";
like image 76
TonyB Avatar answered Nov 26 '25 00:11

TonyB