List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:April 3 1999 10:25am
Subject:Counting rows returned from a SELECT with perl DBI.
View as plain text  
>>>>> "Brian" == Brian Seitz <bds215@stripped> writes:

Brian> I am creating a web-front end to search for database entries and I want
Brian> to split the output into more than one screen (limit 1 , 20, limit 21 ,
Brian> 40, etc.)  But in order to know when to stop allowing the user to press
Brian> "next" and get another screen of results when there are no results left,
Brian> I need to return how many total results exist without the limit
Brian> statement.  Is there a better way to do this than executing the
Brian> statement without the limit and doing a count loop (i.e., "while
Brian> $row_ref = $sth->fetchrow_arrayref { $i++ } )?  It seems like there
Brian> should be some DBI function that returns this automatically.

Brian> ---------------------------------------------------------------------
Brian> Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
Brian> posting. To request this thread, e-mail mysql-thread1325@stripped

Brian> To unsubscribe, send a message to the address shown in the
Brian> List-Unsubscribe header of this message. If you cannot see it,
Brian> e-mail mysql-unsubscribe@stripped instead.

Hi!

The 'fastest' way to solve this is to ask for one extra row with the
LIMIT clause;  You should just not show this last row, but use this to 
determinate if there is more rows to be shown on the next page.

Regards,
Monty
Thread
Counting rows returned from a SELECT with perl DBI.Brian Seitz2 Apr
  • Re: Counting rows returned from a SELECT with perl DBI.Sasha Pachev2 Apr
  • Re: Counting rows returned from a SELECT with perl DBI.Brian Seitz2 Apr
    • Re: Counting rows returned from a SELECT with perl DBI.Vivek Khera2 Apr
  • Re: Counting rows returned from a SELECT with perl DBI.Daniel Koch2 Apr
  • Re: Counting rows returned from a SELECT with perl DBI.Douglas Brantz3 Apr
  • Counting rows returned from a SELECT with perl DBI.Michael Widenius3 Apr