2

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)

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

3 Answers 3

0

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 :)

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

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');
0

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 that you have read and understand our privacy policy and code of conduct.

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