Change part of all two-column records through a reference

Asked

Viewed 143 times

0

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

Details:

  • Columns belong to the same table
  • The part of the record to be removed is common in all Rows, IE, this would be the reference that would use to not change 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 I replace that value www.meussite.com.br, that is so much in the spine PARAMS how much in the column LAYERS for this: www.meunovosite.com.br?

1 answer

2


Use the command UPDATE to update your table, and the function REPLACE 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');
  • I’ll test, if it goes wrong, I’ll kill you :)

  • eUREEECAA, thanks man. You saved yourself.

  • 1

    hahah :) @Lollipop

Browser other questions tagged

You are not signed in. Login or sign up in order to post.