我想使用查询一次选择1000行:
<?php
如何在for循环中从此表中获取下一组1000行?
答案 0 :(得分:0)
我建议您使用$ curl https://bitbucket.org/site/oauth2/access_token \
-d grant_type=client_credentials \
-u dqN7QFLwJEcHsHadYw:pzvZG25WEDqbm9aeUVRHtQRHgTRgDr9t
{
"access_token": "He1rBW1eYAzmT3ePJcvYDtkIcF1Pb1izZHo8oqpKMEL5ivsku71qkjfumVgR2bWsCiRM7XeEmbVffxU92w==",
"scopes": "repository email",
"expires_in": 3600,
"refresh_token": "pfcnxSpXNPAeTcYhcQ",
"token_type": "bearer"
}
$ git clone "https://x-token-auth:JU5dAtlMD30BisLpDkIap7T18Ry9v6p0Xif4owkQUyen_rLx5_B3PjjeqhLhpde0ezR1wyGLeqYE2HA49A==@bitbucket.org/evzijst/crypt"
Cloning into 'crypt'...
remote: Counting objects: 26, done.
remote: Compressing objects: 100% (25/25), done.
remote: Total 26 (delta 8), reused 0 (delta 0)
Unpacking objects: 100% (26/26), done.
Checking connectivity... done.
这样的功能:(我的ROW_NUMBER()
是您的PK)
id
接下来:
SELECT M.*
FROM (
SELECT MEMBERID_1M.*, ROW_NUMBER() OVER (ORDER BY id) As rn
FROM MEMBERID_1M ) M
WHERE
(rn <= 1000)
页面SELECT M.*
FROM (
SELECT MEMBERID_1M.*, ROW_NUMBER() OVER (ORDER BY id) As rn
FROM MEMBERID_1M ) M
WHERE
(rn > 1000) AND (rn <= 2000)
:
:i
答案 1 :(得分:0)
重现answer
只有一种相当复杂的方法可以做到这一点,这对Oracle来说真的很痛苦。他们应该只实现LIMIT / OFFSET条款......
在的where子句选择了行之后,rownum被分配,因此rownum必须始终以1开头。where rownum > x
将始终评估为false。
此外,在完成排序之前,rownum会被分配 ,因此rownum的顺序与订单的顺序不同。
您可以通过子选择来解决这两个问题:
select a,b,c, rn from
( select a,b,c, rownum rn from
( select a,b,c from the_table where x = ? order by c)
where rownum < Y)
where rn > X
如果您不需要排序(但仅限于此),您可以简化为
select a,b,c, rn from
( select a,b,c, rownum rn from the_table where rownum < Y )
where rn > X
答案 2 :(得分:0)
您应该在服务器端进行分页。请使用此查询 更多细节请参考此链接 http://www.oracle.com/technetwork/issue-archive/2007/07-jan/o17asktom-093877.html
select *
from
( select rownum rnum, a.*
from (SELECT * FROM MEMBERID_1M ) a
where rownum <= :M )
where rnum >= :N;