MySQL Forums
Forum List  »  Newbie

Assigning the value of COUNT to a variable
Posted by: Soporose Soporose
Date: August 01, 2009 09:25PM

I've been getting a COUNT and retrieving records using two separate SELECT queries. I figured this wasn't very efficient and after some research and trial and error, I've come with this format:

strSQL = "SELECT DISTINCT *, COUNT(*) AS numRec FROM tablename GROUP BY incidentnumber ORDER BY datetime DESC"

That works fine and returns exactly what I want. But...

What I don't know is how to assign the count value of numRec to a variable so I can use it in code. I've tried a few things like "RS.numRec" and RS("numRec"), but obviously I'm only guessing (unsuccessfully). I'm using Asp/VBScript.

Also, what does the comma after the asterisk signify?

Options: ReplyQuote


Subject
Written By
Posted
Assigning the value of COUNT to a variable
August 01, 2009 09:25PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.