下面是 SQL 语句,我很难放置一个 where 语句来获取匹配生成的分数,并且只返回分数超过 6 的产品。
SELECT product_id, image, title, part_num, price, discount_id, vat,
MATCH (title,part_num,description)
AGAINST ('SEARCH HERE') AS score
FROM main_products AS p
WHERE status = 1
AND MATCH(title,part_num,description) AGAINST ('SEARCH HERE')
ORDER BY score desc, title ASC
我已经尝试过了,但是这不起作用。它会导致此错误:Documentation #1054 - 'where Clause' 中的未知列 'score'
SELECT product_id, image, title, part_num, price, discount_id, vat,
MATCH (title,part_num,description)
AGAINST ('SEARCH HERE') AS score
FROM main_products AS p WHERE status = 1 AND score > 6
AND MATCH(title,part_num,description) AGAINST ('SEARCH HERE')
ORDER BY score desc, title ASC
最佳答案
这个怎么样?
SELECT product_id, image, title, part_num, price, discount_id, vat,
MATCH (title,part_num,description)
AGAINST ('SEARCH HERE') AS score
FROM main_products
WHERE status = 1
AND MATCH(title,part_num,description) AGAINST ('SEARCH HERE')
HAVING score > 6
ORDER BY score desc, title ASC
关于php - MySQL 匹配搜索中的比较运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28675067/