سؤال

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%' 
هل كانت مفيدة؟

المحلول

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
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top