PDA

View Full Version : How to get number of rows returned in MYSQL


brazenskies
08-12-2008, 02:31 PM
Currently in my asp application I run a query to return a result set. I am then running a "select count" query to get the number of results.

Is there a way to do this in asp using just the one select query, which basically returns the results requested AND allows you to display a count.

I believe in php there is something like 'numrows' to do this, but not sure about asp.

Thanks in advance!

Brandoe85
08-12-2008, 02:34 PM
How are you generating the recordset object? There is a RecordCount property but you need to have the correct cursor type, take a look at:
http://www.w3schools.com/ado/prop_rs_recordcount.asp
http://www.w3schools.com/ado/ado_ref_recordset.asp

Good luck;

brazenskies
08-12-2008, 02:41 PM
Not using a cursor at the moment, but I have used them elsewhere so I'll look into employing it here.

Thanks!

Spudhead
08-12-2008, 04:49 PM
use getRows() - that'll turn your recordset into an array. Then you can just do uBound(yourArray,2) to get the row count (it's a sideways array).

hinch
08-12-2008, 05:33 PM
sub select ?

select *, (select count(*) as CNT) from tbl

never used asp and mysql together I know in php there's a row_count() function.