开发者

match ... against on more field: give more importance to first field?

开发者 https://www.devze.com 2023-02-04 05:25 出处:网络
I do a query like this SELECT * FROM . WHERE MATCH(title,text) AGAINST (\'word1\') LIMIT 100 now of coure title is more important than text. Are there a way to tell mysql it should give more revela

I do a query like this

SELECT * FROM . WHERE MATCH(title,text) AGAINST ('word1') LIMIT 100

now of coure title is more important than text. Are there a way to tell mysql it should give more revelance if word1 is found in t开发者_开发问答itle than text?

Thanks


this should do it but its seems a little clunky

SELECT * FROM 

(SELECT * FROM  WHERE 
MATCH(title) AGAINST ('word1') 
UNION
SELECT * FROM  WHERE 
MATCH(text) AGAINST ('word1') 

) t

LIMIT 100
0

精彩评论

暂无评论...
验证码 换一张
取 消