Pregunta

Do you know the method to change a part of a link in a field in a sql table?

Example:

mydomain.ltd/image10.png 

to

newdomain.ltd/image10.png 

This query will delete all the link!

UPDATE users SET avatar = 'newdomain' WHERE avatar like '%mydomain%' 
¿Fue útil?

Solución

you need REPLACE .

Try that:

   UPDATE users SET avatar  = REPLACE(avatar, 'www.xxx.com', 'www.yyy.fr')
   WHERE avatar like '%www.xxx.com%'

this will replace just the word mydomain to newdomain.

  mydomain.ltd/image10.png

to

  newdomain.ltd/image10.png
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top