943,697 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Unsolved
  • Views: 14602
  • MySQL RSS
May 2nd, 2004
0

MySQL RecordCount Problems

Expand Post »
Having built a work around for the counting feature not working, in any of the normal ways Ihave the following problem.

This works perfectly:

<%

RSPage = TRIM(Request.QueryString("page"))

If Len(RSPage)=0Then RSPage =1

Max =10

If RSPage =1Then Offset =0
If RSPage > 1Then Offset =(RSPage-1)* Max

Set
CConn = Server.CreateObject("ADODB.Connection")
CConn.Open strADO
Set CRs = Server.CreateObject("ADODB.RecordSet")

CRs.Open "SELECT COUNT(*) AS PAGECOUNT FROM tblsearch WHERE Active=-1 AND Reference=" & strRefLink, CConn

TotalRecords = CRs("PAGECOUNT")


If(Round((TotalRecords/Max)))= Round((TotalRecords/Max),2)Then
TotalPages = Round((TotalRecords/Max),2)
Else
TotalPages = Round((TotalRecords/Max)+1)
EndIf

IfNot CInt(TotalPages)= CInt(RSPage)Then
If TotalRecords < Max Then
PageSwitch = False
Else

PageSwitch = True
End
If
EndIf

CRs.close
CConn
.close
%>

I also need it to work with the following SQL but have failed in all attempts so far.

"SELECT *, MATCH (url,description,name) AGAINST ('" & Search & "' IN BOOLEAN MODE) AS score FROM tblsearch WHERE Active=-1 AND MATCH (url,description,name) AGAINST ('" & Search & "' IN BOOLEAN MODE) ORDER BY name ASC LIMIT " & Offset & "," & Max

The MATCH command seems to be causing a problem when combined with the COUNT(*) feature,


The String above works fine on its own, but not with COUNT(*).


Can anyone help? :rolleyes:


Anthony

Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
SD2001 is offline Offline
1 posts
since May 2004
Sep 6th, 2006
0

Re: MySQL RecordCount Problems

The COUNT(*) method was used only with GROUP BY statement.
So, if you have some colums in SELECT statement YOU MUST insert also a GROUP BY statement in your sql string.

I've solved this problem, deleting all columns in select statement [inserting only count(*)], and manteining the other part the same.

Bye.

PS. I'm italian and i've not a lot of experience with english language.
Studing it its different to write it.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bronko85 is offline Offline
1 posts
since Sep 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MySQL Forum Timeline: Connections in loops
Next Thread in MySQL Forum Timeline: MySQ-help...





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC