-- get the Nth record from the top:
select *
from tblname
order by id asc
limit N-1,1
-- get the Nth record from the bottom:
select *
from tblname
order by id desc
limit N-1,1

Regards,
-Toby


>Hi all
>I create a table like this:
>sqlite3_exec(db, "CREATE TABLE TBLNAME (ID 
>INTEGER PRIMARY KEY , NAME TEXT)", 0, 0,&zErrMsg);
>Then insert some records, the follow is the 
>contents of this table.
>-------------------------------------
>ID                       NAME
>==================
>(1)      1                         AA
>(2)      2                         BB
>(3)      3                         CC
>(4)      4                         DD
>(5)      5                         EE
>(6)      6                         FF
>(7)      7                         GG
>--------------------------------------
>Then may delete some records,
>-------------------------------------
>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" .
>The N value is given, and how can do it fast?
>Thanks                     Yoky
>_______________________________________________
>sqlite-users mailing list sqlite-users@sqlite.org
>http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

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

Reply via email to