我想更新提供以下用户名的user_placement_id
对应user_placement
列。我想使用引用用户名的user_placement_id
更新user_placement
。
user_id | user_name | user_placement | user_placement_id
--------+-----------+----------------+-------------------
1 | jone1 | jone2 | 0
2 | jone2 | jone1 | 0
3 | jone3 | jone2 | 0
4 | jone4 | jone3 | 0
答案 0 :(得分:0)
我认为你可以在这里使用更新自我加入:
UPDATE yourTable t1
INNER JOIN yourTable t2
ON t1.user_placement = t2.user_name
SET t1.user_placement_id = t2.user_id;