Shijin Shijin - 10 months ago 40
SQL Question

Search text containing a new line in 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";


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";