Jump to content

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


limitphp

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.