Skip to:
Content
Pages
Categories
Search
Top
Bottom

How do you ‘Find and Replace’ a word in the BP Activity table in the Database?

  • Avatar of rossagrant
    rossagrant
    Participant

    @rossagrant

    Basically, I have changed my admin’s display name on my site and this changes the display name EVERYWHERE but in past activity stream posts.

    I can manually change the name in each post in the activity table in the DB but there are 141 instances.

    Is there a way to search and replace the name automatically?

    Thanks

    Ross :)

Viewing 7 replies - 1 through 7 (of 7 total)
  • Avatar of rossagrant
    rossagrant
    Participant

    @rossagrant

    Any ideas on this people? I see there are strings of SQL to achieve things like this.

    Avatar of Travel-Junkie
    Boris
    Participant

    @travel-junkie

    That would be something like this:
    `UPDATE [tablename] SET [fieldname] = replace([fieldname],’[string_to_find]‘,’[string_to_replace]‘);`

    You’ll need to substitute stuff like [tablename] with the correct values.

    Avatar of rossagrant
    rossagrant
    Participant

    @rossagrant

    @travel-junkie Cheers Boris! Gonna have a play around on a test DB to see if I can get this to work! :)

    Avatar of rossagrant
    rossagrant
    Participant

    @rossagrant

    Hmm… tried this but am told the syntax is wrong

    UPDATE [wp_bp_activity]
    SET [action] = replace([action],’[admin1]‘,’[admin2]‘);

    I’m trying to change all mentions of the admin’s original name, with the new name in the wp_bp_activity table to display the new name in old stream items.

    Anything obviously wrong with that?

    Does filedname refer to the column the string is found in the DB? That’s what I’ve used.

    Avatar of Travel-Junkie
    Boris
    Participant

    @travel-junkie

    Don’t include the [ ] in the syntax :)

    So it’d be like this:
    `UPDATE wp_bp_activity SET action = replace(action,’admin1‘,’admin2‘);`

    Avatar of rossagrant
    rossagrant
    Participant

    @rossagrant

    Hahaha, nice one Boris! I’ll test it out! ;)

    Avatar of rossagrant
    rossagrant
    Participant

    @rossagrant

    @travel-junkie Cheers Boris, just got around to testing this, and it works a treat without brackets!

    Changed 145 rows in under a second! Saved me A LOT OF TIME!

    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.