-1

In table XXX I have a column YYY with links:

htttp://mysiteddress/items/cat32/2a.pdf
htttp://mysiteddress/items/cat32/3a.pdf
htttp://mysiteddress/items/cat32/4a.pdf
.
.
.

I want to make a query that change cat32 into cat22 but I have no idea how to do that. Could anybody help me?

I assume it should be made somehow with UPDATE query...

tapitap
  • 3
  • 2
  • 3
    Read [How to Ask](http://stackoverflow.com/help/how-to-ask), as is this is off topic for multiple reasons! –  Oct 19 '14 at 04:16
  • possible duplicate of [Update a column value, replacing part of a string](http://stackoverflow.com/questions/10177208/update-a-column-value-replacing-part-of-a-string) – ROMANIA_engineer Oct 19 '14 at 08:34
  • How is it unclear what tapitap is asking? – Abe Miessler Oct 19 '14 at 16:47
  • I think it's about title. I have changed it. Got -1 after my first post... One more post and I will be put to prison :P Anyway thank you guys for help. I checked your solutions and though they seem reasonable they don't work. But maybe I just do something wrong or there is other cause so I wrote to my host support. I hope they will tell me what to do about that. – tapitap Oct 19 '14 at 17:31
  • I was going to post here a solution unfortunately I didn't get any useful information from host support. If I solve somehow the problem I will tell what to do. – tapitap Oct 21 '14 at 17:00

2 Answers2

2

Give this a shot:

UPDATE XXX SET YYY = REPLACE(YYY, 'cat32', 'cat22')
Abe Miessler
  • 82,532
  • 99
  • 305
  • 486
  • Ok, now this works :) I have no idea why it didn't work but after my contact with host everything is ok. Thank you very much. Unfortunately I cannot give you any point as my reputation is too low... – tapitap Oct 21 '14 at 18:51
  • Hey @tapitap, you should be able to accept my question by clicking the checkmark to the left if you feel like it is the best answer. Cheers! – Abe Miessler Oct 21 '14 at 21:37
  • 1
    Done :) I can do something similar for powermock, but I don't know how. His link is useful as well. – tapitap Oct 22 '14 at 03:15
0

This will produce that result for you:

UPDATE XXX SET YYY = REPLACE(YYY, 'cat32', 'cat22')

but it will also replace

htttp://mysiteddress/items/cat32/2cat32a.pdf  

to

htttp://mysiteddress/items/cat22/2cat22a.pdf 

which might not be needed so in that case to support preg replace in mysql use lib_mysqludf_preg library

gloomy.penguin
  • 5,833
  • 6
  • 33
  • 59
Somil
  • 567
  • 5
  • 13