How to change multiple records in a sql table at once?

3

Imagine a result of an SQL:

ID - NOME- MENSAGEM

1 / israel / msg-olamundo
2 / rafael / msg-olamundo
3 / augusto / msg-olamundo

Now I want to do in SQL the same thing that str_replace would do in php to pull all records from one x to the word "msg -".

Searching found the answer and wanted to put it here to help the guys is very easy!

    
asked by anonymous 20.08.2014 / 17:06

1 answer

4
update tabela
   set mensagem = REPLACE(mensagem, 'msg-', 'NOVO TEXTO AQUI OU DEIXAR VAZIO PARA APAGAR') 
 where 'mensagem' LIKE '%msg-%'
    
20.08.2014 / 17:07