比如数据库中有这样的id字段,且是主键,以下为删除记录之后的id的编号:
1
3
4
9
21
35
38
想问一下如何得到当前记录的上一条和下一条记录呢?
比如当前记录是9如何通过sql语句得到下一条(21)上一条(4)呢.?谢谢帮忙,虽然这个问题有点刺手,还
是请大家帮我一下,谢谢了
1
3
4
9
21
35
38
想问一下如何得到当前记录的上一条和下一条记录呢?
比如当前记录是9如何通过sql语句得到下一条(21)上一条(4)呢.?谢谢帮忙,虽然这个问题有点刺手,还
是请大家帮我一下,谢谢了
解决方案 »
- 识别验证码
- asp.net 生成 PDF
- 没分了,请大家帮帮忙
- 怎样用FreeTextBox向数据库里修改数据?
- 我想在一个自定义类中调用 Response.Write("字符")这应该怎么做到?
- 请教各位大哥,关于Exchange 2007 的二次开发问题
- 在asp.net为什么会一直提示项目出错?
- 请问各位告诉朋友,这http://www.denisbauer.com/ASPNETControls/HierarGridDemo.aspx效果是怎么做出来的,答案一出就揭帖
- asp.net的skin文件中控件可以嵌套吗?
- 如何新增XML新节点?
- 为什么众多的Asp.Net程序员不喜欢界面编程?
- "相关文章"这个功能怎么实现啊?
select top 1 id as preid from table a where a.id < 9 order by a.id desc
union all
select top 1 id as nextid from table a where a.id > 9 order by a.idoracle:
select id as preid from table a where a.id < 9 and rownum = 1 order by a.id desc
union all
select id as nextid from table a where a.id > 9 and rownum = 1 order by a.id
select top 1 * from article where insro='pro' and id>9 order by ID
上一条,下一条也类似
在table2中加一列ID从1开始,2.3.4......N
本函数只可与SELECT INTO 表 一起用。
select identity(int,1,1) as id,* into table2 from table1
在table2中加一列ID从1开始,2.3.4......N