http://qs321.pair.com?node_id=92451

dsb has asked for the wisdom of the Perl Monks concerning the following question:

Hey monks, I am in a situation where I need to the count of rows returned by a 'SELECT' query. However, I have read that the DBI::rows function is unreliable at best. After having tried to think of other ways to get a row count on a query, the best I could come up with was:
$sth = $dbh->prepare("SELECT name FROM people WHERE l_name LIKE 'B%'") +; $sth->execute(); while ( $name = $sth->fetchrow_array() ) { $count++; }
I was wondering if there is a less verbose, and perhaps more efficient way of getting a row count. Processing the results of the query is completely unnecessary to this script, so it seems kind of silly to have to loop through all of them. Thanks in advance.

Amel - f.k.a. - kel