mysql update from 子查询

来源:互联网 发布:linux 查看go语言版本 编辑:程序博客网 时间:2024/04/28 09:58

这个破问题纠结了我好久,查了mysql的好多资料,最后还是在别人那里得到结果,特此记录一下,留个备份吧!


mssql 子查询更新

update log set uin= b.uin
from log a,logs b
where a.accountuin = b.accountuin

mysql 不支持 update 子查询更新

找了半天资料 终于搞定了...

update `log` a inner join `logs` b on a.`accountuin` = b.`accountuin`
set a.`uin` = b.`uin` where a.`accountuin` = b.`accountuin`

这样就能 将查询出来的字段批量更新过去了...

原创粉丝点击