如下所示如何以我的格式执行查询.... [英] How to execute Query as my Format like below....

查看:73
本文介绍了如下所示如何以我的格式执行查询....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:

1.我的表有100条记录,并且在网页中显示了100条记录.
2.根据主键ID升序排列(从1到100).



我的问题是,

记录分为1-10、11-20、21-30,...,91-100.

然后如何编写查询

如果是第一次执行,则
显示 1-10、11-20、21-30,...,91-100.

如果第二次执行,则
显示 11-20 ,21-30、31-40,...,91-100, 1-10 .

如果第三次执行,则
显示 21-30 ,31-40、41-50,...,91-100, 1-10、11-20 .

等等....


如何以上述格式显示....


重播我...

解决方案

  SELECT   10  *  FROM  myTable  ORDER   ViewState [" ] = " ] =  1  +( int )ViewState [" ]; 


并将其设置为变量,并将视图状态值作为其参数传递.

  SELECT   TOP   10  *  FROM  myTable  WHERE  ID>(@ value * 10)


Note:

1. My table has 100 records and I display that 100 records in web page.
2. Order by ascending (1 to 100) based on primary key id.



My Question is,

Records are split into like, 1-10, 11-20, 21-30 ,..., 91-100.

then How to write Query for

if execute first time then
display 1-10, 11-20, 21-30, ..., 91-100.

if execute Second time then
display 11-20, 21-30,31-40, ..., 91-100, 1-10.

if execute third time then
display 21-30, 31-40, 41-50, ..., 91-100, 1-10, 11-20.

and so on....


How to display like above format....


replay me...

解决方案

SELECT TOP 10 * FROM myTable WHERE Id>10 ORDER BY Id

and pass a new value for ID for each page.


each time you exacute the page , put value in querystring or viewstate the number of exacution:

ViewState["NoEx"] = 1;
ViewState["NoEx"] = 1 + (int)ViewState["NoEx"];


and set as a variable and pass the view state value as its parameter.

SELECT TOP 10 * FROM myTable WHERE Id>(@value*10) 


这篇关于如下所示如何以我的格式执行查询....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆