redarrow
Expert Member
- Joined
- Dec 30, 2005
- Messages
- 2,411
Hey all,
If I use a query like: "SELECT * FROM mytable WHERE <condition> LIMIT 0,10"
What's the best method to determine if there more rows available?
Obviously if less than 10 rows are returned I know that there are no more. But if 10 are returned I can't tell if there are any more of if there are only 10...
So far the only solution I can think of is to always set LIMIT to one more than I need and just ignore the extra row if it exists (it's existence confirms that there are more rows than the amount I need).
Now the only problem with this is it seems like a waste, requesting a record which doesn't really get used. I know in small databases this is a non issue, but I'd really like to know if there is a "correct" way of doing it..
Sorry if this question seems a bit pointless, seeing as I do actually have a solution
I just don't want to get into the habit of using my solution if there is a better one available.
Thanks.
If I use a query like: "SELECT * FROM mytable WHERE <condition> LIMIT 0,10"
What's the best method to determine if there more rows available?
Obviously if less than 10 rows are returned I know that there are no more. But if 10 are returned I can't tell if there are any more of if there are only 10...
So far the only solution I can think of is to always set LIMIT to one more than I need and just ignore the extra row if it exists (it's existence confirms that there are more rows than the amount I need).
Now the only problem with this is it seems like a waste, requesting a record which doesn't really get used. I know in small databases this is a non issue, but I'd really like to know if there is a "correct" way of doing it..
Sorry if this question seems a bit pointless, seeing as I do actually have a solution
I just don't want to get into the habit of using my solution if there is a better one available.
Thanks.