I can't seem to find any info about this on the internet (or I'm just not looking in the right direction).
I have a few fields in my MySQL database containing a carriage return and line break \r\n .
Is there somebody who can tell me how to find them by using a query??
SELECT * FROM mytable WHERE mycolumn REGEXP "\r\n"; finds all records in mytable where mycolumn contains a \r\n sequence. At least in MySQL Workbench for Windows, when I used the " (double quote) from your answer, it was translated into a newline in my query and didn't work. I had to use ' (single quotes.)
Using SQL to remove a line feed or carriage return means using the CHAR function. A line feed is CHAR(10); a carriage return is CHAR(13).
-- Using both \r\n SELECT 'First line. \r\nSecond Line. ' AS 'New Line'; -- Using both \n SELECT 'First line.
SQL Carriage Return (CR): The Carriage Return moves the cursor to the beginning of the line. It does not move to the next line. Line feed (LF): The line feed moves the cursor to the next line. It does return to the beginning of the line.
SELECT * FROM mytable WHERE mycolumn REGEXP "\r\n";
finds all records in mytable
where mycolumn
contains a \r\n
sequence.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With