0

I'm having a table like this called v3_product_description.

+------------+-------------+-------------+--------------------------------------------------------------------+----------+--------------------------------------------------------------------+--------------------+------------+--+
| product_id | language_id |    name     |                            description                             |   tag    |                          meta_description                          |   meta_keywords    | meta_title |  |
+------------+-------------+-------------+--------------------------------------------------------------------+----------+--------------------------------------------------------------------+--------------------+------------+--+
|          1 |           2 | Test        | descrition about product. Altijd op voorraad. further description. | tag      | descrition about product. Altijd op voorraad. further description. | keywords           | title      |  |
|          2 |           1 | test        | Beschrijving over het product                                      | tagsss   | metabeschrijving Altijd op voorraad                                | keywords,and so on | title      |  |
|          3 |           2 | Tessdslfkjq | product description                                                | moretags | metadescription Altijd op voorraad                                 | keywords,bullshit  | titlestuff |  |
+------------+-------------+-------------+--------------------------------------------------------------------+----------+--------------------------------------------------------------------+--------------------+------------+--+

As you guys can see the phrase Altijd op voorraad is very common in my table (I have over 8000 rows in the real database).

Altijd op voorraad translated to German is Immer auf Lager and the language_id for German is 2.

I'm trying to search and replace that phrase in my tables so I came up with this query:

SELECT product_id, language_id, name, description, tag, meta_title, meta_description, meta_keyword,
       REPLACE(meta_description,'Altijd op voorraad','Immer auf Lager')
FROM v3_product_description
WHERE language_id = 2

This query should change every Altijd op voorraad in column meta_description to Immer auf Lager. But once executed it doesn't seem to do so when I view the items in my web-shop.

What am I doing wrong? And how to apply the same search/replace at column description? Should I do this with a 2nd query or can those 2 be combined?

jarlh
  • 42,561
  • 8
  • 45
  • 63
Baklap4
  • 3,914
  • 2
  • 29
  • 56
  • One guess are "special" characters. In other words, perhaps the vowels have accents. – Gordon Linoff Dec 15 '15 at 12:30
  • As you can see in the examples i've given, there are no special characters in those sentences neither are there special characters in the replace function. – Baklap4 Dec 15 '15 at 12:31
  • 1
    You are only replacing in the read column data. You need to do UPDATE to change the actual table data. – jarlh Dec 15 '15 at 12:41

1 Answers1

2

You are trying to update the column value, but are using a select query.

The correct way to replace your string in the meta_description column would be to

UPDATE v3_product_description

SET meta_description= REPLACE (meta_description,'Altijd op voorraad','Immer auf Lager')

WHERE language_id = 2

Hope this helps. Cheers!

bIgBoY
  • 417
  • 2
  • 12
  • Thanks this was the answer! I forgot to actually update the values.. wow blue tuesday instead of a blue monday. I really feel stupid now – Baklap4 Dec 15 '15 at 12:37
  • 1
    @Baklap4 happens to the best of us. Feel free to mark the answer as accepted if it solves your problem. Cheers – bIgBoY Dec 15 '15 at 12:38
  • 1
    Will do when i'm able to mark it solved! – Baklap4 Dec 15 '15 at 12:39