1 SELECT 2 * 3 FROM 4 ( 5 SELECT 6 *, 7 ROW_NUMBER ( ) OVER ( ORDER BY Id DESC ) AS RowIndex 8 FROM 9 ( 10 SELECT 11 [p].[Sysno] AS [Sysno], 12 [p].[Productname] AS [ProductName], 13 [pr].[Productphotourl] AS [ProductPhotoUrl], 14 [p].[Typename] AS [TypeName], 15 [p].[Id] AS [Id] 16 FROM 17 [Products] p, 18 [Productphotos] pr 19 WHERE 20 ( [p].[Sysno] = [pr].[Sysno] ) 21 ) MergeTable 22 WHERE 23 ( [ProductName] LIKE '%五金%' AND [TypeName] LIKE '%产品%' ) 24 ) T 25 WHERE 26 RowIndex BETWEEN 1 27 AND 5
这里的分页SQL 用了嵌套查询,那么我猜测有两种情况,第一种是只查询5条数据。第二种猜测是最里面一个子查询把所有数据查询出来,然后保存到内存里面,后面外层的分页查询在去内存里面取5条出来。
RowIndex BETWEEN 1 AND 10 再怎么也不是5条啊 有没有可能是你的数据只有5条 才让你这么思考的
bu好意思说错了 是10条
没人没人没人没人没人