mysql怎么做关联更新?

telankes2000 2012-04-06 09:30:08

update a set a.discount = b.adjust_fee from tm_order_info a INNER JOIN
(
select order_sn,sum(adjust_fee) adjust_fee from tm_order_goods where order_sn in('20120224-725029049' ,'20120309-735313946','20120304-731334448','20120312-738124285','20120315-739599869',
'20120315-740373841','20120316-741076263','20120308-734709036','20120316-741041930','20120308-734400252','20120314-739698366','20120324-748335914',
'20120326-749938179','20120319-743458941','20120326-750145173','20120319-743636576','20120325-749622020','20120316-741414890','20120331-754313444','20120325-749134947','20120320-744278223'
)GROUP BY order_sn
)b on a.order_sn=b.order_sn
语法错误 应该怎么改?
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from tm_order_info a INNER JOIN
(
select order_sn,sum(adjust_fee) adjust_fee' at line 1

...全文
131 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
ACMAIN_CHM 2012-04-06
  • 打赏
  • 举报
回复
update tm_order_info a INNER JOIN
(
select order_sn,sum(adjust_fee) adjust_fee from tm_order_goods where order_sn in('20120224-725029049' ,'20120309-735313946','20120304-731334448','20120312-738124285','20120315-739599869',
'20120315-740373841','20120316-741076263','20120308-734709036','20120316-741041930','20120308-734400252','20120314-739698366','20120324-748335914',
'20120326-749938179','20120319-743458941','20120326-750145173','20120319-743636576','20120325-749622020','20120316-741414890','20120331-754313444','20120325-749134947','20120320-744278223'
)GROUP BY order_sn
)b on a.order_sn=b.order_sn
set a.discount = b.adjust_fee
WWWWA 2012-04-06
  • 打赏
  • 举报
回复
update tm_order_info a INNER JOIN
(
select order_sn,sum(adjust_fee) adjust_fee from tm_order_goods where order_sn in('20120224-725029049' ,'20120309-735313946','20120304-731334448','20120312-738124285','20120315-739599869',
'20120315-740373841','20120316-741076263','20120308-734709036','20120316-741041930','20120308-734400252','20120314-739698366','20120324-748335914',
'20120326-749938179','20120319-743458941','20120326-750145173','20120319-743636576','20120325-749622020','20120316-741414890','20120331-754313444','20120325-749134947','20120320-744278223'
)GROUP BY order_sn)b on a.order_sn=b.order_sn

set a.discount = b.adjust_fee

56,677

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧