skip to Main Content

I am having trouble writing a SQL Statement that would update and replace all the values in my WordPress Database. I am a really just trying to replace all value of wp_capabilities with wp_130638636_capabilities in my meta_key column inside my wp_130638636_usermeta table.

See my screenshot below:

phpmyadmin
For example the line below will change one row:

UPDATE wp_130638636_usermeta SET meta_key = ‘wp_130638636_capabilities’ WHERE wp_130638636_usermeta.umeta_id = 6175;

But instead I only want to change the values of the meta_key that are wp_capabilities to wp_130638636_capabilities. If that value in meta_key doesn’t have wp_capabilities, then the value shouldnt change.

Is this correct:

UPDATE wp_130638636_usermeta SET meta_key = ‘wp_130638636_capabilities’ WHERE meta_key = wp_130638636;

2

Answers


  1. I believe that this is the correct statement. Update the column meta_key where meta_key is equal to ‘wp_capabilities’ to the new value ‘wp_130638636_capabilities’ This will not update any null values.

    UPDATE
      meta_key
    SET
      meta_key = 'wp_130638636_capabilities'
    WHERE
      meta_key = 'wp_capabilities';
    
    Login or Signup to reply.
  2. Update wp_130638636_usermeta Set meta_key =
        replace(meta_key, 'wp_capabilities', 'wp_130638636_capabilities')
    

    Try this, I have just tried and it worked like a charm.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search