WordPress.org

Ready to get started?Download WordPress

Forums

SQL query to update account information? (3 posts)

  1. war59312
    Member
    Posted 8 years ago #

    Hey,

    All right, a little back story first. ;)

    A few years ago I deiced to start a blog for school. At the time it was private and on a intranet domain. I've left hundred of comments over the years. Of course since then, all of my account information has changed, and multiple times at that. That is, my posting name (user name), E-mail, and URI.

    Today I use plug-ins such as Author Highlight, which help my comments stick out from the rest. That is, so it's easy to tell when I, the lone administrator, has left an official comment.

    So now I would like to change the SQL data for all of my old comments so that they all have my valid account information. With the bonus being, that Author Highlight and other plug-ins will work for all comments, instead of just new ones that include my updated account information.

    I believe an SQL query will do this easily, the problem being I am a complete newbie and have no clue where I would even begin. Basicly, I only now how to display data.

    Which is like this:

    SELECT *
    FROM
    wp_comments
    WHERE
    comment_author = 'oldAuthor'
    OR
    comment_author = 'newAuthor'
    AND
    comment_author_email = 'old@address.com'
    OR
    comment_author_email = 'new@address.com'
    AND
    comment_author_url = 'http://www.oldsite.com/'
    OR
    comment_author_url = 'http://www.newsite.com/'
    ORDER BY
    comment_ID ASC
    LIMIT 0 , 30

    380 Total

    So those 380 are all of my comments.

    All the old ones need to be updated with my new account information.

    Wow, that would suck big time having to do it by hand. Got to love the power of SQL. :)

    Thanks a lot,

    Will

  2. pizdin_dim
    Member
    Posted 8 years ago #

    This will work:

    update
    wp_comments
    set
    comment_author='NEW_AUTHOR',
    comment_author_email='NEW_EMAIL',
    comment_author_url='NEW_URL'
    where
    comment_author='OLD_AUTHOR'
    ;

  3. war59312
    Member
    Posted 8 years ago #

    All right sweet! :)

    Thanks a lot.

    Worked great! :D

Topic Closed

This topic has been closed to new replies.

About this Topic