与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');
答案 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');