I am trying to copy the first name to the display name. I created a temporary table call wp_tmp_usermeta. And did a join. However, no rows affected. Whhyyyyyyyy?
Error Message: 0 rows affected. (Query took 0.0213 seconds.)
UPDATE
`wp_usermeta`
JOIN (SELECT `meta_value`,`user_id` FROM `wp_tmp_usermeta` WHERE `wp_tmp_usermeta`.`meta_key` = 'first_name') newtable ON newtable.`user_id` = `wp_usermeta`.`user_id`
SET
`wp_usermeta`.meta_value = newtable.meta_value
WHERE
`wp_usermeta`.meta_key = 'nickname' ;
Desired result is to copy the value of first_name to nickname
If you want to copy (i.e. really duplicate the rows) the first name but keyed as nickname, you don't need a temporary table and no UPDATE
. You want an INSERT ... SELECT
.
INSERT INTO wp_usermeta
(meta_key,
meta_value,
user_id)
SELECT 'nickname',
meta_value,
user_id
FROM wp_usermeta
WHERE meta_key = 'first_name';
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments