Welcome to WebmasterWorld Guest from 54.162.155.183

Forum Moderators: open

Message Too Old, No Replies

MySQL Match HAVING Score

trying to bring back an accurate match count based on score

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

5+ Year Member



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.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month