You dont have to do that just adjust as such
UPDATE post SET pagetext = REPLACE(pagetext, '-med.','.')
You wanna get things on one pass and above is probally the easiest since you want to get all png gif and jpg in one pass. I doubt your going to match anything in a post like -med. that would need to be replaced
Then the second one will adjust the url path