我有三个表user,user_status,owner。
id,userId,ownerId
1, 1001, 0
2, 1002, 0
3, 1003, 0
userId, ownerId
1001, 2001, ....
1002, 2002, ....
1003, 2003, ....
ownerId, name ...
0, ...
2001, ...
2002, ...
我想用对应于实际userIds的ownerIds更新user_status表。因此,更新后user_status表如下所示。
1, 1001, 2001
2, 1002, 2002
3, 1003, 2003
没有存储过程是否可以这样做?
答案 0 :(得分:0)
update user_status set ownerId = (select ownerId from user where user.userId = user_status.userId)