homepage Welcome to WebmasterWorld Guest from 54.204.249.184
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
MySQL Match HAVING Score
trying to bring back an accurate match count based on score
ronnieb




msg:4288234
 8:39 pm on Mar 27, 2011 (gmt 0)

I am trying to bring back a count based on scores over a certain value. Here's my code in my PHP script that calls the database.

SELECT count(MATCH ( `title`) AGAINST ('+(apples) ' IN BOOLEAN MODE )) as Score FROM `inventory` WHERE MATCH ( `title`) AGAINST ('+(apples) ' IN BOOLEAN MODE) HAVING Score > 1;

The problem is the count returned is always the total of all matches in my database regardless of how high I make the score.

So if I say HAVING Score > 9 it still returns the same as HAVING Score > 1.

How do I return an actual count based on how many lines actually match the Score setting?

FYI when I pull the actual data without a count, the script only pulls the data that matches the score.

Here is an actual data pull

SELECT *, MATCH ( `title`) AGAINST ('+(apples) ' IN BOOLEAN MODE ) as Score FROM `inventory` WHERE MATCH ( `title`) AGAINST ('+(apples) ' IN BOOLEAN MODE) HAVING Score > 1

and that will bring back only matches that match the Score set as well. So this one works fine, just can't get an accurate count based on Score.

 

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved