如何更新排行榜?

LJR999 2006-01-31 10:07:01

我碰到一个问题。


我想根据表[abc]中的字段[aaa]的排序来更新字段[bbb]的数据。

id aaa bbb
75 732 1 ←如何更新字段bbb这样?
22 372 2
93 277 3
12 86 4
.. .. ..

看我写的,哪里出了问题。谢谢!



top=1
set rs= conn.execute("select * from [abc] order by aaa desc")
if rs.eof then
call error()
else

do while not rs.eof
id=rs("id")
response.write "<b>"&top&"</b>"
conn.execute("update [aaa] set bbb="&top&" where ID="&id&"")
top=top+1

rs.movenext
loop

end if
...全文
99 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
opolmzy 2006-02-01
  • 打赏
  • 举报
回复
SELECT IDENTITY(int, 1,1) AS ID_Num,aaa from [abc] order by aaa desc
INTO #t

生成临时表#t

--------------------------------------

drop #t

删除临时表#t
LJR999 2006-01-31
  • 打赏
  • 举报
回复
↓这里?
SELECT IDENTITY(int, 1,1) AS ID_Num,aaa from [abc] order by aaa desc
INTO #t

update [abc] set [abc].bbb = ID_Num from [abc] inner join #t
on [abc].aaa = #t.aaa
select * from [#abc]
drop #t ←这里?
LJR999 2006-01-31
  • 打赏
  • 举报
回复
您好,可以加点解释吗?
zhangjsl 2006-01-31
  • 打赏
  • 举报
回复
SELECT IDENTITY(int, 1,1) AS ID_Num,aaa from [abc] order by aaa desc
INTO #t

update [abc] set [abc].bbb = ID_Num from [abc] inner join #t
on [abc].aaa = #t.aaa
select * from [#abc]
drop #t

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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