基于MySQL中的连接2表的WordPress更新语句

时间:2017-09-19 07:38:20

标签: php mysql wordpress

我有两个数据表

'wp_balance' table with column Balance, and userid 

另一张表:

 'wp_users' table with column userid and referredby

userid在两个表中都很常见,其中referredby是不同的用户ID。我需要在referredbywp_balance

中更新wp_balance.userid=wp_users.userid成员余额

1 个答案:

答案 0 :(得分:0)

$sql = "UPDATE wp_balance SET balance = $sum FROM wp_balance JOIN wp_users
               ON wp_balance.userid = wp_users.userid;