Limiting size of a returned resultset in mySql in the query? - preCharge Forums
It shows that you are unregistered. Please register with us by clicking Here
preCharge Forums


Nav Green LeftNav Right
preCharge Forums > Website Design & Development > Programming > PHP » Limiting size of a returned resultset in mySql in the query?


Reply
Tcat Right
 
LinkBack Thread Tools Display Modes Tcat Right
Old 07-13-2006   #1 (permalink)
hailey
Junior Member
 
Join Date: Jul 2006
Age: 43
Posts: 9
Default Limiting size of a returned resultset in mySql in the query?

Hi,

I have a query that I am using in a paginated page

e.g. "select * from news"

what I want to do is for the first page get the first 20 say and then for the second get from 21 to 40 and so on.

Is this possible in the query?

I can obviously code it up to do the logic in PHP but that’s going to be inefficient and people might laugh at me behind my back.

Thanks,
Hailey
hailey is offline   Reply With Quote


Old 07-14-2006   #2 (permalink)
Francisjr
Member
 
Join Date: Jul 2006
Age: 28
Posts: 61
Default

Try using

SELECT * FROM NEWS LIMIT 20

the operator LIMIT limits the size of the result set to 20.
Francisjr is offline   Reply With Quote

Old 07-14-2006   #3 (permalink)
imehesz
Senior Member
 
imehesz's Avatar
 
Join Date: Jul 2006
Age: 30
Posts: 258
Default here

here is a nice explanation:
PHP Code:
SELECT FROM tbl LIMIT 5,10;  # Retrieve rows 6-15 

you can take a look at this link too:
http://dev.mysql.com/doc/refman/5.0/en/select.html
__________________
--
iM
imehesz is offline   Reply With Quote

Old 08-02-2006   #4 (permalink)
Ankita
Member
 
Join Date: Jul 2006
Age: 25
Posts: 53
Default Re: Limiting size of a returned resultset in mySql in the query?

Just use
Quote:
LIMIT
to specify how many records you want to show.
Ankita is offline   Reply With Quote

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Query Correct? gabriel Site and Server Administration 1 07-21-2006 08:01 AM


footer left
All times are GMT. The time now is 09:00 PM.

DISCLAIMER: preCharge Risk Management is not responsible for any opinions, advice or comments expressed on the preCharge Community Forums.
preCharge® is a registered trademark of preCharge Risk Management | chargeback protection | Merchant Account Blog

Powered by vBulletin
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC6

Loans | Salvage yard | Mortgage Calculator | Personal Loan | MPAA

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49