skip to Main Content

I have a database with products and each product also contain a field with its description. Problem is, the old site used a ‘funny old SEO technique’ in wich manages added a phrase after each product description, take a look below. I’m trying to find the best way to programatically delete this phrase from product’s description field using either regex in mysql queries or php.

The text in the field (varchar) is something like this:

Powder for mixing with water-based paint. 1KG recipients.

All our products have been tested and certified. Buy now from now and
we will offer you free shipping for orders above 100 Euros

I need to remove the phrase starting with

All our products…….

Can I do this directly in mysql or do I need to make a PHP script?

Thanks

2

Answers


  1. Chosen as BEST ANSWER

    I used this code

    update productdescriptions
        set description = substring_index(description, 'All our products', 1)
        where description like '%All our products%';
    

  2. Here is a pretty simple way:

    update productdescriptions pd
        set field = substring_index(pd.field, 'All our products', 1)
        where pd.field like '%All our products%';
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search