List:MySQL++« Previous MessageNext Message »
From:Warren Young Date:September 14 2010 6:39pm
Subject:Re: Get the number of rows with a "used" query.
View as plain text  
On Sep 14, 2010, at 3:25 AM, m p wrote:

> So : is it possible to get the numbers of rows returned by a query using the
> mysqlpp::UseQueryResult object ?
> (Without obviously looking through all tuples)

Not without making the database server do a second table scan ahead of the "use" query.

The least inefficient way to ask it to do that is to use the COUNT function:

e.g. SELECT COUNT(*) FROM my_table WHERE some_col=value;

That will tell you how many rows in my_table have the given some_col value.  Beware that
if the table is changed between the COUNT query and "real" query, the count can be off. 
It may be possible to guarantee an accurate count by wrapping both queries in a
transaction, but I couldn't say for sure.

> And is it maybe possible to seek back in the query results ?

No.  MySQL limitation.
Get the number of rows with a "used" query.m p14 Sep
  • Re: Get the number of rows with a "used" query.Warren Young14 Sep
Re: Get the number of rows with a "used" query.Warren Young15 Sep