How can I replace (\n) in SQL with a Line Breaks? i want to do it with a SQL query,

I want in table: catalog_product_entity_text replace the value with Line Breaks instead of (\n)

  • Export that table,then you can apply find and replace on notepad++.then import again after truncate that table Commented Jun 10, 2018 at 4:45

3 Answers 3


you also added </n> tags and </br> tags but not break line so you use <li> tags same like this example:-

<li> your description write </li>

I hope this way helpful

try to this way :)

  • i want to do it with a SQL query. 32000 records.
    – MaartenV1
    Commented Nov 30, 2017 at 14:10
  • Sorry, not helpful, because this is not a SQL query
    – MaartenV1
    Commented Dec 1, 2017 at 7:30

You can use following sql queries to replace \n with <br> .

UPDATE catalog_product_entity_text SET value = REPLACE (value, '\\n', '<br>');

A general sql query to find and replace a matching character is given below:

UPDATE tablename SET column_name = REPLACE(column_name, 'matching_string', 'replace_with');

This is what we have used. Looked up the attribute_id for the short description, removed the carriage returns \r and replaced the new lines \n with <br>

UPDATE catalog_product_entity_text SET value = REPLACE(REPLACE (value, '\n', '<br>') , '\r', '')
WHERE attribute_id = ( 
                SELECT `attribute_id` FROM `eav_attribute` WHERE `attribute_code` = "short_description" LIMIT 1 ); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.