分页查询SQL语句

来源:互联网 发布:威少本赛季数据 编辑:程序博客网 时间:2024/06/09 23:07

http://www.cnblogs.com/aito/archive/2010/08/27/1810494.html

 

 select top m * from UserInfo where UserId not in

(select top (n-1)*m UserID from UserInfo order by UserID asc) order by UserID asc

 

如果记录集合有100万条 not in集合可能会会很慢
 .... id not in(1,2,3,4,5,.....,1000000)....
SQLITE的分页查询:limit n,m;  从第n条往后查m条:
 SELECT * FROM [sft_task] ORDER BY Id ASC limit n,m;
原创粉丝点击