专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Access

求一句sql(,解决马上结帖)

发布时间:2010-05-20 14:01:29 文章来源:www.iduyao.cn 采编人员:星星草
求一句sql(在线等,解决马上结帖)
如下表T
2个字段
id     index
1       1
2       2
3       3
4       4
5       5
6       6
8       8
9       9
现在要将index> =5   and   index <=6   这2条记录的index加上一个数
这个数的值等于id=2的index的值减去id=5的index的值(这里就是2-5)
我的想法是这样的
update   T   set   index=index+(select   index   from   T   where   id=2)-(select   index   from   T   where   id=5)   where   index   between   5   and   6

请教高手要怎么写才能实现这个效果

------解决方案--------------------
try


update T , (select index from T where id=2) A, (select index from T where id=5) B set T.index=T.index+A.index-B.index where T.index between 5 and 6
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: