我有2张桌子。 wp_users和wp_users_backup。它只是一个副本。表格如下所示:
wp_users
user_login|user_pass
user1 |pasword94545
user2 |pasword5920
列user_pass具有不同的值。如何从wp_users_backup更新列user_pass,其中user_login =等于表wp_users?
答案 0 :(得分:0)
试试这个:
UPDATE wp_users_backup
SET user_pass =
(SELECT user_pass FROM wp_users WHERE user_login = wp_users_backup.user_login);
它应该有用。
答案 1 :(得分:0)
我相信你想恢复备份表中的值,
所以,你可以使用更新连接:
UPDATE wp_users a
JOIN wp_users_backup b ON a.user_login = b.user_login
SET a.user_pass = b.user_pass
答案 2 :(得分:0)
你有几种方法可以做到这一点: 1:使用表表达式
With ABC
AS
(
select a.user_login, a.user_pass as old, b.user_pass as new
from wp_users inner as a join wp_users_backup as b
on b.user_login = a.user_login
)
Update ABC
SET ABC.old = ABC.new
2.使用相关查询
Update wp_users as a
set user_pass = (select user_pass from wp_users_backup as b where b.user_login = a.user_login )