tableA
col1 col2 ...
1 2 ...
3 4 ...tableB
col1 col2 ...现在要
update tableB set col1 = (select sum(col1) from tableA where ...)
col2 = (select sum(col2) from tableA where ...)
where ...可不可以不用中间变量 又只进行一次select完成这件事情
col1 col2 ...
1 2 ...
3 4 ...tableB
col1 col2 ...现在要
update tableB set col1 = (select sum(col1) from tableA where ...)
col2 = (select sum(col2) from tableA where ...)
where ...可不可以不用中间变量 又只进行一次select完成这件事情
解决方案 »
- 求SQL查询语句(图书管理系统查询借阅次数)
- 求一个大数据量的数据库MDF文件,想要测试SQL语句查询效率
- MSDE2000局域网内不能登录,请指点,谢了!
- 有关删除重复记录的2个问题
- 不知ON [PRIMARY]是什么意思
- 如何把某个固定的行排在最后??
- 关于SQL SERVER版本升级的问题(100分)
- 請問各位:如何在查看已建好的SQL SERVER數據庫的觸發器有哪些?難道要一個表一個表的查看嗎???另,請問李維有沒有網站?多謝
- ★★★快来抢85分★★★:我建一个更新记录的触发器,当我用一条更新语句更新3条记录时,为何只触发一条记录?
- 那位老兄知道在sqlserver中如何区分insert触发器和after insert 触发器?
- 删除一条纪录后identity值如何重新排列
- 如何先查前100条记录 然后在判断?
比如:
update a set col1 =b.col ,col2 =b.col2
from tableB
join (select sum(col1) as col1,sum(col2) as col2 from tableA where ...) b on
where ....
col2 = (select sum(col2) from tableA where ...)
where ...
可以的阿