/    Sign up×
Community /Pin to ProfileBookmark

Mysql query syntax?

$result = mysql_query(“SELECT * FROM yesterday ORDER BY points DESC LIMIT 0,5”) ;

what i want to do is skip the first 5 rows
and get the second 5 rowes (rows 6-10)
know any ways of doing this ?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogOct 12.2009 — LIMIT 5, 5

...or...

LIMIT 5 OFFSET 5

Note that in the first format (comma-separated), the first number is the offset and the second the number of rows, while that is inverted for the second format. How's that for confusing? ?
Copy linkTweet thisAlerts:
@thraddashOct 12.2009 — Just because I was asked on my profile:

[code=php]$result = mysql_query("SELECT * FROM yesterday ORDER BY points DESC LIMIT 0,5") ; //1-5
$result = mysql_query("SELECT * FROM yesterday ORDER BY points DESC LIMIT 5,5") ; //6-10
$result = mysql_query("SELECT * FROM yesterday ORDER BY points DESC LIMIT 10,5") ; //11-15

$page_size = 5;
$page_num = 2;
$result = mysql_query('SELECT * FROM yesterday ORDER BY points DESC LIMIT ' . ($page_size * ($page_num - 1)) . ',' . $page_size, $conn) ;[/code]
Copy linkTweet thisAlerts:
@robertbarzykauthorOct 12.2009 — thanks alot to the both of you

im new at php

but im good at learning, im building a very complex site right now

and im expecting very high traffic

im afraid i might go over my cpu usage

i talked to my hosting provider and they said i max out at like 15%

=/ any good hosting you know of with high cpu usage cheap?
×

Success!

Help @robertbarzyk spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...