求update 语句写法

baoqingfeng 2004-03-19 02:13:02
update a set a.id=b.id from (select id from c group by id) as b where a.id=b.id
基本意思是想更新本表的数据,数据是从另一张子句中查出来的.按照我这样写不对
...全文
48 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
baoqingfeng 2004-03-19
  • 打赏
  • 举报
回复
maimaizhi(mutiny) 答对了.全给你了
baoqingfeng 2004-03-19
  • 打赏
  • 举报
回复
update report_service as a set a.money=c.money from (select sum(fee) as money,service_id from b group by service_id) as c where c.service_id=a.service_id;
提示错误是as 附近有语法错误
baoqingfeng 2004-03-19
  • 打赏
  • 举报
回复
我重新说明一下,大概是如下意思:
update report_service as a set a.money=b.money from (select sum(fee) as money,service_id from b group by service_id) as c where c.service_id=a.service_id;
LoveSQL 2004-03-19
  • 打赏
  • 举报
回复
写的不清楚啊
jinsfree 2004-03-19
  • 打赏
  • 举报
回复
思路不明确,表达的不清楚
maimaizhi 2004-03-19
  • 打赏
  • 举报
回复
update table1 set id=b.id from table1 as a,(select id from c group by id) as b where a.id=b.id
Mybeautiful 2004-03-19
  • 打赏
  • 举报
回复
update a set a.col1 =b.col1 from tabl1 a left outer join table2 b on a.id=b.id
火电 2004-03-19
  • 打赏
  • 举报
回复
update a set a.id = c.id from a,c
ttkkyy 2004-03-19
  • 打赏
  • 举报
回复
问一句,查询的纪录a.id已经与b.id相等了
为什么还要修改为a.id=b.id
Mybeautiful 2004-03-19
  • 打赏
  • 举报
回复
update table1 a set a.col1 =b.col1 left outer join table2 b on a.id=b.id
火电 2004-03-19
  • 打赏
  • 举报
回复
什么错误提示???

34,575

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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