Naz
Naz

Reputation: 910

Remove string from field using MySQL

I want to remove the string;

<p><span style="color: #008000;">-- Instant Download --</span></p>

from a the field description_short in the table ps_product_lang I have tried the following SQL query

update ps_product_lang set description_short = replace(description_short, ‘<p><span style="color: #008000;">-- Instant Download --</span></p>’, ‘’);

But I get the error message

"#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '>-- Instant Download --

’, ‘’)' at line 1"

I believe its the quotes and --< that may be the issue, does anyone know how to make the query work> Thanks

Upvotes: 0

Views: 204

Answers (2)

why not to do the replace by PHP and after update the full field in mysql? Maybe is not the most correct way, but it works and is easy and fast to code that solution.

Upvotes: 0

Gordon Linoff
Gordon Linoff

Reputation: 1269583

This is your code:

update ps_product_lang
    set description_short = replace(description_short, ‘<p><span style="color: #008000;">-- Instant Download --</span></p>’, ‘’);

The only problem that is obvious to me are the curly single quotes. Try replacing them with regular single quotes:

update ps_product_lang
    set description_short = replace(description_short, '<p><span style="color: #008000;">-- Instant Download --</span></p>', '');

Upvotes: 2

Related Questions