-
MySQL - limit question
Hi,
I am using this query in my code:
Code:
select * from REQUESTINFO rq, REPLY r where rq.id = r.requestid order by rq.date desc limit 0, 10
Unfortunately it does not limit the records to the first 10 - I get the whole 3000. I also need to return an arbitrary y records starting at record x, hence the 'limit x,y' syntax
I have tried the following variations:
limit 10 - returned 3k+ rows
limit 0,10 - ditto
limit 0, 10 - ditto
limit 0 , 10 - ditto
limit 0 - ditto
limit 10,10 - ditto
MySQL version is 3.23.42
Cheers
Mark H
-
paginating data
did you check your sql syntax, I think the right code is:
select * from REQUESTINFO as rq, REPLY as r where rq.id = r.requestid order by rq.date desc limit 0, 10
(for the first page) and then
select * from REQUESTINFO as rq, REPLY as r where rq.id = r.requestid order by rq.date desc limit 11, 21
(for the second page) and next.. (limit 22,31 and next)
you can using incremental variables like
<?php if(!isset($page)||$page<0)$page=0;
$dispnum=10;
?>
<a href=\"show.php?p=<?php echo $page;?>show last page</a>
<a href=\"show.php?p=<?php echo $page+$dispnum;?>show next page</a>
try to dicussion & learn on http://www.devshed.com (goods for beginer) or http://phpbuilder.com (posting it close now, but have good article)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|