PhpMyAdmin SQL command to change a word

Discussion in 'MySQL' started by soniqhost.com, Jan 23, 2011.

  1. #1
    Can someone please tell me what the SQL Command line is to update a field.

    For example, the table name is wp_usermeta, the fields are meta_key and meta_value. I'm looking to replace a:1:{s:6:"author";b:1;},with a:1:{s:11:"contributor";s:1:"1";} which is under field meta_value throughout the field.

    I hope I explained it well, any help would be greatly appreciated.
     
    soniqhost.com, Jan 23, 2011 IP
  2. mysqlxpert

    mysqlxpert Greenhorn

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #2
    Use MySQL's REPLACE() function. See MySQL manual on using function (http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_replace)
     
    mysqlxpert, Jan 24, 2011 IP
  3. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #3
    Query would be something like this:

    
    UPDATE wp_usermeta SET meta_value = REPLACE(meta_value, 'a:1:{s:6:"author";b:1;}', 'a:1:{s:11:"contributor";s:1:"1";}');
    
    Code (markup):
     
    mastermunj, Jan 25, 2011 IP