mysql 多表更新

来源:互联网 发布:大旗软件 编辑:程序博客网 时间:2024/05/23 13:47
 UPDATE yi_user a
set 
freezeamt=freezeamt-
(
select sum(fee) from bp_drawout b
where 
b.srcType='Y'
and b.dstatus=4
and b.srcid=a.yuid
GROUP BY
b.srcid
),
amt=amt+
(
select sum(fee) from bp_drawout b
where 
b.srcType='Y'
and b.dstatus=4
and b.srcid=a.yuid
GROUP BY
b.srcid
)
where 
a.yuid in (
select b.srcid from bp_drawout b
where 
b.srcType='Y'
and b.dstatus=4
GROUP BY
b.srcid
原创粉丝点击