易截截图软件、单文件、免安装、纯绿色、仅160KB

sql分页问题 - .NET技术 / ASP.NET

select top 3 stuid from pagesize where stuid not in (select top 3 stuid from pagesize order by id asc) order by id asc这里的分页sql语句为什么要加上排序呢?不排序不行吗?我看到很多sql语句分页代码在括号外面和里面都有排序!能具体说下什么吗?或者有其他的例子来说一下!??
id stuid
1 1
2 2
3 2
4 2
5 2
6 5
7 6
8 7
9 8
10 8
11 9
12 10//对于这个表sql语句select top 3 stuid from pagesize where stuid not in (select top 3 stuid from pagesize order by id asc) order by id asc 为什么输出的不是2,2,5呢?
如果是倒序的话 括号外面和里面都要加上排序 因为是反起来的
默认排序方式是asc 你这个不加排序也是正确的

用order by是保证子查询和外面的主查询看到的是“同一张表”(记录顺序相同),这样才能达到分页的效果。

主查询的 top 3 表示选择3条记录(每页记录数),子查询的 top 3 表示跳过的记录数(页号*每页记录数)

分页查询应当用主键id,不应当用stupid,因为它有重复记录显然不是主键

引用
对于这个表sql语句select top 3 stuid from pagesize where stuid not in (select top 3 stuid from pagesize order by id asc) order by id asc 为什么输出的不是2,2,5呢?

输出不是2,2,5吗?

SELECT TOP 页大小 *
from TestTable
WHERE (ID NOT IN
  (SELECT TOP 页大小*页数 id
  from 表
  ORDER BY id))
ORDER BY ID

SELECT TOP 页大小 *
from TestTable
WHERE (ID >
 


相关问答:

在asp.net里面脚本出错 - .NET技术 / ASP.NET

function CheckOpwd(){//验证用户名
var pwd=document.all.txtOpwd;

var div1=document.getElementById("divPwd");

if (pwd.value=="")
{
......

数据以xml格式返回 - MS-SQL Server / 应用实例

从数据库中查询一张表的数据
select 部门,姓名 from tb
如何才能生成下面的xml格式
XML code:
<folder state="unchecked" label="全部">
   <folder state="unchecked&qu ......

求一SQL - MS-SQL Server / 基础类

tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......

wap网站开发的问题 - .NET技术 / ASP.NET

我用.net开发wap网站
1,我从工具箱里拖了两个link,这两个link会显示在两行,如果让这两个link处于同一行。
2,如何显示两个控件之间的空格问题。
跟wap有关吗?不太明白

友情帮顶。。。。。。。。。。

就 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号