-2

I'm trying to replace a specific piece of text. I have no experience at all with mysql.

The table (content) has a column ( keywords ) containing all kind of words separated by comma. I want to replace tekst with text.
Important: the whole string contains many other combined values with partly tekst in it which i DO NOT want to replace.

Example: tekst, tekst one, tekst two, teksting, foo, bar, should be replaced by text, tekst one, tekst two, teksting, foo, bar,

I tried this but it replaced all by only text and erased the rest

UPDATE content
SET keywords=text
WHERE keywords=tekst;
razz
  • 41
  • 1
  • 9
  • Use replace, plz go through tutorials if you are new https://www.mysqltutorial.org/mysql-string-replace-function.aspx/ – Pals Jun 12 '20 at 13:45
  • 2
    Does this answer your question? [Update a column value, replacing part of a string](https://stackoverflow.com/questions/10177208/update-a-column-value-replacing-part-of-a-string) – billyonecan Jun 12 '20 at 13:47
  • @billyonecan It does not unfortunately. – razz Jun 12 '20 at 14:40

1 Answers1

1

You could use the replace function:

UPDATE content
SET    keywords = REPLACE(keywords, 'tekst', 'text')
WHERE  keywords LIKE '%tekst%'
Mureinik
  • 297,002
  • 52
  • 306
  • 350
  • It's close. I should have mentioned in my post that I only want to replace tekst and not other keywords that have "tekst" in it. So when I want to replace tekst in tekst, tekst1, tekst2, weather, sun, moon it should only replace tekst and leave tekst1 and tekst2 as is. – razz Jun 12 '20 at 14:37