Escape line breaks in MySQL output

SELECT REPLACE(
    REPLACE(yourcolumn, '\r', '\\r'),
    '\n',
    '\\n'
) FROM yourtable;

Leave a Comment