Jump to content

Limit number of listings

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
Guest_NeedHelp_*

Guest_NeedHelp_*
  • Guests
Is there a way in MySQL to limit how many results are shown?

SELECT * FROM tbl;

but I only want say, 25 results. Is this possible?

#2
smith

smith

    Programmer

  • Members
  • PipPipPipPip
  • 153 posts
Yup, just add a LIMIT 0,25

The 0 is where to start and the 25 is the max number of results.

for (int i;;) {

   cout << "Smith";

}


#3
smith

smith

    Programmer

  • Members
  • PipPipPipPip
  • 153 posts
SELECT * FROM tbl LIMIT 0,25;

for (int i;;) {

   cout << "Smith";

}


#4
husky44

husky44

    Learning Programmer

  • Members
  • PipPipPip
  • 30 posts
I know there is a command for Top 10 or something.. how does that one work?
Sorry to slightly stray here, but it is still kind of relevant.

#5
Guest_Jordan_*

Guest_Jordan_*
  • Guests
You can do a ORDER BY to get the top ten combined with limit

SELECT * FROM tbl ORDER BY clm_num LIMIT 0,10;

Do to in reverse order do

SELECT * FROM tbl ORDER BY clm_num LIMIT 0,10 DESC; // Descending Order

You can also ORDER by multiple columns in your table

SELECT * FROM tbl ORDER BY clm_num, clm_name LIMIT 0,10;

If the column is character it will be sorted alphabetical.