分页SQL语句
做网站开发的都知道,显示列表项过多时会采取分页。本文主要讨论分页中的SQL语句,仅供参考。
以下是C#中的参数化的SQL语句片段,展示了分页时的情况:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
string strSql = @"select top(@num) * from ( select id, c_info_title, count(*) over() AS Total, row_number() over(order by n_is_head, n_order desc, d_list_date desc, id desc) AS num from B_NEWS where n_is_active=1 ) AS T where num>@index"; SqlParameter[] paras ={ new SqlParameter("@num", perPageCount) new SqlParameter("@index", perPageCount*(curPage-1)) }; |
&nbs[……]