Jump to content

[SOLVED] How do you get the actual number of records returned when using LIMIT?


Recommended Posts

If I use a LIMIT x,y in a sql query, how do i get the actual number of records returned for that page?

 

In other words, I don't want to get the total number that would have been returned if there were no LIMIT, I want to get the actual number returned with the LIMIT?

I had typed this out before you posted, so I'm going to post this anyways (hate to waste my time)

 

odd question.  If your limit is larger than the total found, then a

SELECT COUNT(*) as `total_found` FROM `table_name` LIMIT 100;

will return the table `total_found`, which has the total it found.  If the number is larger than your limit, then that means it reached its limit, so implementing "LIMIT" does no good.

 

Let me explain:

 

Lets say I ran this query:

SELECT COUNT(*) as `total_found` FROM `ip_range`;

and lets say I received this result:

total_found
-----------
512

Ok, I now know that if I set my limit to 100, it will find 100. I also know that if I set my limit to 1024, the maximum that will turn up is 512. Is that making any sense?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.