Change part of all records of two columns through a reference

0

Good evening, everyone! I am noob in SQL and I want to strive to learn more with your help.

Details:

  • The columns belong to the same table
  • The part of the record to be taken is common on all rows, that is, this would be the reference you would use to not change the wrong information!

CONSULTATION:

ID - PARAMS                                                          - LAYERS 
1 / {"image":"http:\/\/www.meussite.com.br\/imagens_a\/banner1.png"} /  ....
2 / {"image":"http:\/\/www.meussite.com.br\/imagens_c\/banner2.png"} /  ....
3 / {"image":"http:\/\/www.meussite.com.br\/imagens_b\/banner3.png"} /  ....
...

How do I replace this value www.meussite.com.br , which is both in the PARAMS column and the LAYERS column by this: www.meunovosite.com.br ?

    
asked by anonymous 26.02.2015 / 00:54

1 answer

2

Use the UPDATE command to update your table, and the REPLACE function to replace the values:

UPDATE nome_tabela
SET params = REPLACE(params, 'www.meussite.com.br', 'www.meunovosite.com.br'),
    layers = REPLACE(layers, 'www.meussite.com.br', 'www.meunovosite.com.br');
    
26.02.2015 / 01:00