如何得到数据表中的第N条记录?ID字段不是连续的
来源:百度知道 编辑:UC知道 时间:2024/07/07 21:12:19
比如,我要得第3条记录,或者第20条记录,没有任何可筛选的条件,就是要找数据表中的第N条数据。ID字段又是不连续的
问同事
用游标
declare 游标名 scroll cursor
for select * from 表名
open 游标名
fetch absolute 3 from 游标名
close 游标名
deallocate 游标名
select top 1 * from table where id not in (select top n-1 id from table)
通过rownum就可以获取,如果是Oracle的话
你ID是不是标识列吧?