yokk y <[EMAIL PROTECTED]> wrote:
>           -------------------------------------
>  ID                       NAME
>           ==================
>   (1)    1                         AA
>   (2)    3                         CC
>   (3)    4                         DD
>   (4)    6                         FF
>   (5)    7                         GG
>           --------------------------------------
>   I want to find the Nth record, for example?when N=3 , I want to get
> this record  : "4           DD" , N=5 : "7       GG" .

select * from TBLNAME
order by ID
limit 1 offset :N - 1;

> The N value is
> given, and how can do it fast?

By "fast", I assume you mean "in time faster than O(N)". Basically, to
do this you would have to renumber the rows every time one row is
deleted (e.g. by using a trigger). Then you can simply do

select * from TBLNAME where ID=:N;

which will run in O(log T) where T is the total number of rows in the
table. But of course, now every deletion takes O(T). If you need to
select often enough and delete rarely enough, that may be a worthwhile
tradeoff.

Igor Tandetnik 



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to