Link to home
Start Free TrialLog in
Avatar of Nathan Riley
Nathan RileyFlag for United States of America

asked on

Query Replace Help

I'm trying to do a replace on a filed that has many different options.

filedname = post, table = posts

[url=http://domain.com/blah.flv]blah video[/url]
[url=http://domain.com/video/name.mp4]name of him[/url]
[url=http://domain.com/video/2001/funny.flv]funny clip[/url]

Open in new window


I want to update these to make them look like:

[media]http://domain.com/blah.flv[/media]
[media]http://domain.com/video/name.mp4[/media]
[media]http://domain.com/video/2001/funny.flv[/media]

Open in new window

Avatar of Ephraim Wangoya
Ephraim Wangoya
Flag of United States of America image

update table
set fieldname = REPLACE(fieldname, '')

update table
set fieldname =REPLACE(fieldname, '
', '[/media]')
Avatar of Nathan Riley

ASKER

can you put all that in code tags so I can see it,  the url tags disappeared haha.
Here
update table
set fieldname = REPLACE(fieldname, '')

update table
set fieldname =REPLACE(fieldname, '', '[/media]')

Open in new window

Not that, let me redo
Here is the correct one
update table
set fieldname = REPLACE(fieldname, '[url=', '[media]')

update table
set fieldname =REPLACE(fieldname, '[/url]', '[/media]')

Open in new window

Well, that still doesn't get me there that will make the result set be:
[media]http://domain.com/blah.flv]blah video[/media]
[media]http://domain.com/video/name.mp4]name of him[/media]
[media]http://domain.com/video/2001/funny.flv]funny clip[/media]

Open in new window


but what I need is:
[media]http://domain.com/blah.flv[/media]
[media]http://domain.com/video/name.mp4[/media]
[media]http://domain.com/video/2001/funny.flv[/media]

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial