1

I have a database with a table name called mybb_users.

All users have a field name called avatar. Some users have their avatar set as

 http://graph.facebook.com/userid/picture?width=250&height=250. 

I want to mass-replace all the width and height of the people that use a facebook picture with this amount of width and height. I unfortunately don't know how to do this since the userid is random. Is there anyway I can mass replace width=250&height=250 to width=140&height=140 ?

Thank you!

Andrey Morozov
  • 7,839
  • 5
  • 53
  • 75

2 Answers2

2

you can do it with the REPLACE function:

UPDATE mybb_users
SET avatar = REPLACE(`avatar`, 'width=250&height=250', 'width=140&height=140')
WHERE avatar like '%graph.facebook%'

for further information have a look at: http://dev.mysql.com/doc/refman/5.6/en/string-functions.html#function_replace

chresse
  • 5,486
  • 3
  • 30
  • 47
0

You can update just the portion you want like this:

UPDATE mybb_users SET avatar = REPLACE(avatar, 'width=250&height=250', 'width=140&height=140')

this should replace all occurences of the 250 with 140

Silvertiger
  • 1,680
  • 2
  • 19
  • 32