十七度
首页
(current)
动态
节点
工具
注册
登录
首页
技术
MySQL
MySQL通过子查询更新
saonian
发布于 18/12/06 09:36
256 点击
一般情况下可能会直接上来这么写 ```mysql update sqd_a set amount = amount * 0.1 where id in (select id from sqd_b where is_dividend = 1 and get_time < 1); ``` 但是会直接报错 [1093] **You can't specify target table 'sqd_a' for update in FROM clause** 正确的写法是这样的 ```mysql update sqd_a as a,(select id from sqd_b where is_dividend = 1 and get_time < 1) as b set a.amount = a.amount * 0.1 where a.id = b.id; ```
mysql
ount
whereidin
amount
写法
andget_time
0 评论
请登录后发表评论
saonian
all or nothing, now or never.
文章
234
回复
247
粉丝
15
关注
6