id name table user
1 aaa
2 bbb
3 ccc
4 bbb
ip area user_id table t
1 bbb null
2 ccc null
3 aaa null
4 ccc null
怎样将user表中的id值赋给t表中的user_id
------解决方案--------------------
什么数据库?
update t from t inner join user on t.area=user.name
set t.user_id=user.name
------解决方案--------------------
- SQL code
update t set user_id=(select id from user where name=area)