PHP PDO全文,按相关性分数限制

时间:2011-11-03 11:07:37

标签: php mysql pdo

Limit to only relevant results - MYSQL相似,我需要根据得分限制返回的结果,例如3

这是我的查询,但它不起作用:

$STH = $DBH->prepare('SELECT 
                        id
                        , MATCH (title,edition) AGAINST (:query) AS score
                        , 3 as score 
                      FROM hb_articles 
                      WHERE MATCH(title,edition) AGAINST(:query IN BOOLEAN MODE) 
                      order by score desc');

1 个答案:

答案 0 :(得分:1)

您正在将别名score重新定义为常量3

将查询重写为:

SELECT  
  id 
  , MATCH (title,edition) AGAINST (:query IN BOOLEAN MODE) AS score 
FROM hb_articles  
WHERE MATCH(title,edition) AGAINST(:query IN BOOLEAN MODE)  
HAVING score <= 3   //or >= 3 I always forget how match against works.
ORDER BY score DESC');