title: MySQL / Classic ASP - Record Count
body: <p>I'm trying to add a count of all returned records in to my query, but having some issues. It's a very large query so I won't post it all.</p>
  
  <p>When this executes, I get all records but the count rs.Fields("totalRecCount") always returns with 1. Can anybody see what I am doing wrong and suggest a fix?</p>
  
  <p>This is the top part:</p>
  
  <pre><code>Set cmdConn = Server.CreateObject("ADODB.Command")
  Set cmdConn.ActiveConnection = Conn
  cmdConn.Prepared = True
  
  Const ad_varChar = 200
  Const ad_ParamInput = 1
  Const ad_Integer = 3
  
  selectClause = "SELECT COUNT(photoID) AS totalRecCount, photoID FROM photoSearch "
  whereClause = "WHERE photoStatus = 'Live' "
  </code></pre>
  
  <p>This is the bottom part:</p>
  
  <pre><code>groupBy = "GROUP BY photoID "
  orderClause = "ORDER BY dateCreated DESC "
  
  SQL = selectClause &amp; whereClause &amp; groupBy &amp; orderClause &amp; limitClause
  cmdConn.CommandText = SQL
  
  Set rsPhotoSearch = cmdConn.Execute
  </code></pre>