On Sat, Dec 27, 2003 at 02:08:08PM +0000, Abs wrote:
> hi
> i was trying to group my results 10 per page ($p per
> per page). if i use limit, then there's no way of
> knowing how many there are left so i can't give page
> numbers as:
> << first 2 3 4 last >>. perhaps running the query
> twice, first time wihtout limit to see how many there
> were and the 2nd just for a particular bunch with
> limit. wouldn't that load the mysql db? and what if
> i've got 10,000 rows or so? the query will take time.
> any solutions?

Use SQL_CALC_FOUND_ROWS.
Documented in http://www.mysql.com/doc/en/SELECT.html

You run your first query with SQL_CALC_FOUND_ROWS, then once you're
done with it, you run another ("SELECT FOUND_ROWS()") and you get the
total resultcount you would have got, had you not LIMIT'ed it.

-- 
Chris

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to