Chris Chris - 2 years ago 91
MySQL Question

Changing forum content tags in string column

In the process on migarting from one forum software to another I have been left with mis-matched embedded BBCodes in hundreds of posts.

For example this is the content of one post:

Luke Kelly - Raglan Road + Lyrics

My new forum expects:

Luke Kelly - Raglan Road + Lyrics

It's beyond my SQL abilities to substitute the tags.

The table name is
and the field name is

Any help would be appreciated, thanks.

Answer Source

Simple UPDATE command with nested replace(string, string, string) would work:

UPDATE xf_post
  message = replace(replace(message, '[video]', '[MEDIA]'),'[/video]','[/MEDIA]'));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download