Chris Chris - 10 months ago 47
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]'));