您好,登录后才能下订单哦!
sql数据分页有几种方法,首先用最简单最原始的方法,选择top10:
select top 10 * from Student where id not in(select top(10*@pageIndex) id from Student order by id) order by id
查询出来的结果:
其他方法:
select * from /*分页查询所有数据*/ (select *,row_number() ober(order by id desc) as num /*row_number()定义新行为num*/ from student) as table /*查出新表名为 table*/ where table.num between 0*10+1 and 1*10 /* 从新表table中查询第0页到第一页的数据 每页10条*/
还有一种就是选择从多少到多少的记录的sql分页语句
select * from (select *,row_number() over (order by Id asc) as num from T_Products) as s where s.num between 3 and 5;
说明:C#创建数据对象模型的时候,如果数据库中对应的字段可能为空,那么对象模型的属性在创建的时候就要判断,如果是值类型的就必须要写成int?number,如果是引用类型的则不需要,例如string类型就属于引用类型的,数据库中是null的话,对应读取到的还是null。
==================== 迂者 丁小未 CSDN博客专栏=================
MyBlog:http://blog.csdn.net/dingxiaowei2013 MyQQ:1213250243
Unity QQ群:858550 cocos2dx QQ群:280818155
====================== 相互学习,共同进步 ===================
转载请注明出处:http://blog.csdn.net/dingxiaowei2013/article/details/17429383
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
开发者交流群:
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。