In the last episode (Jul 18), S A said: > Is there some way to take the following 2 queries & make them into > one ? Nope. Do them separately (or do the count(*) once and cache it for the rest of the session). > I want to be able to in one query get the # of overall rows and do a > LIMITed result set to get the first NN rows. > > Is it possible to to do this in one query ? Presumable MySQL has to > figure out what the overall # is to return the limited result set so > it'd be more efficient to do this all at once. No, mysql doesn't have to calculate the entire resultset; all it needs to do it get the first record. If you had 1 million records with group_id=1, it could take a long time to calculate the count(*). > SELECT COUNT(*) FROM posts WHERE group_id=1; i.e. find first group_id index entry with the value of '1', scan forward in the index until value != 1, return count. > SELECT post_subject FROM posts WHERE group_id=1 LIMIT 10,10; i.e. find first group_id index entry with the value of '1', skip 10 entries, then for the next 10 entries (assuming there are still records with value of '1'), fetch the appropriate data record and return 'post_subject' to the user. -- Dan Nelson [EMAIL PROTECTED] --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php