If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > MySQL RecordCount Problems

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-02-04, 06:47
sd2001 sd2001 is offline
Registered User
 
Join Date: May 2004
Posts: 4
MySQL RecordCount Problems

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
EndIf
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?


Anthony
Reply With Quote
  #2 (permalink)  
Old 05-02-04, 07:25
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by sd2001
The String above works fine on its own, but not with COUNT(*).
probably because you had other stuff in the SELECT besides count(*)

also, no need to use ORDER BY or LIMIT, as there will be only 1 row with 1 count in it

Code:
select count(*)
  from tblsearch 
 where active=-1 
   and match (url,description,name) 
       against ('" & search & "' in boolean mode)
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 05-02-04, 07:32
sd2001 sd2001 is offline
Registered User
 
Join Date: May 2004
Posts: 4
Many thanks r937, worked first time.

Anthony
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On