Hey guys,
What is the easiest way to limit the number of results returned by a query (e.g. limit 20...) while returning the total number of database matches.. (e.g. john has 28 friends... )
in that case you wouldn't want to show all returned results.
thanks
Andrew
Getting total number of matches while limiting return.
Moderator: General Moderators
- seppo0010
- Forum Commoner
- Posts: 47
- Joined: Wed Oct 24, 2007 4:13 pm
- Location: Buenos Aires, Argentina
I think found_rows() is the easier way.
I´m not sure if it works in a SQL besides MySQL.
I´m not sure if it works in a SQL besides MySQL.
Yeah, I didn't know about that either. Usually I would've ran two separate queries to get that information, or made some clever use of count().
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
I read in "MySQL vs. PGSL" forums that using SQL_CALC_FOUND_ROWS/FOUND_ROWS(), indeed makes MySQL engine execute two separate queries, so it's not so good as it sounds 
Just keep in mind about this and performance
Just keep in mind about this and performance
There are 10 types of people in this world, those who understand binary and those who don't
True I guess, but it'd only have to parse and optimise the query once and it might do other internal optimisations like storing information about the first 'pass' so it'd still be much quicker than doing the query twice yourself.VladSun wrote:I read in "MySQL vs. PGSL" forums that using SQL_CALC_FOUND_ROWS/FOUND_ROWS(), indeed makes MySQL engine execute two separate queries, so it's not so good as it sounds
Just keep in mind about this and performance