Answer the question
In order to leave comments, you need to log in
How to influence the relevance of MySQL fulltext search?
Columns in the table: id, text, source I
use the usual query:
SELECT * FROM `articles` WHERE MATCH (text) AGAINST ('database');
Answer the question
In order to leave comments, you need to log in
Lines with 'auto' are always in front:
SELECT *
FROM (
SELECT *, MATCH `text` AGAINST('database') AS `score`
FROM `articles`
) AS `t`
WHERE `score` > 0
ORDER BY `source` != 'auto', `score`
SELECT *
FROM (
SELECT *, MATCH `text` AGAINST('database') AS `score`
FROM `articles`
) AS `t`
WHERE `score` > 0
ORDER BY `score`+(`source` = 'auto')*0.5 DESC
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question