Reputation: 1
I'm selecting text from a full-text mysql dbTable, hits are returned ordered by relevance multiplied by a client supplied weight. The query works fine, though I'd like to as an "AS score" clause to the query to return the actual weighted relevance scores back to the client (via php). I've tried inserting the AS clause everywhere, with no success. Suggestions? Thank You
$sql1="SELECT * FROM $dbTable
WHERE MATCH (data) AGAINST ('".$key_word_1."')
OR MATCH (data) AGAINST('".$key_word_2."')
ORDER BY (MATCH (data) AGAINST('".$key_word_1."') * $weight_1) + (MATCH (data) AGAINST('".$key_word_2."') * $weight_2) DESC
LIMIT 200";
Upvotes: 0
Views: 1657
Reputation: 4773
you can do this:
SELECT * , (MATCH (data) AGAINST('".$key_word_1."') * $weight_1) + (MATCH (data) AGAINST('".$key_word_2."') * $weight_2) AS score
....
ORDER BY score DESC
Upvotes: 1