【发布时间】:2013-04-07 04:46:57
【问题描述】:
我想得到一个结果并根据最相关的排序 .这是一个mysql表
id sentence
1 website download free idm here
2 get a free idmas5 from here
3 check out this idm
4 Here is other softwares
这是一个代码。
<?php
$word1 = 'download';
$word2 = 'idm';
mysql_query("SELECT * FROM phrase WHERE MATCH(sentence)
AGAINST('+$word1 +$word2' IN BOOLEAN MODE"))
//above query does not work
我想从MATCH.....AGAINST 获取结果并像这样对结果进行排序。
必需的结果。
1 website download free idm here
3 check out this idm
2 get a free idmas5 from here
因为 download 和 idm 都存在于第一个 id 中,所以它在顶部,而在第三个 id 中只有 idm 存在在第二个位置。在第二个 id 中这个词 idmas5 是从 idm 开始的,所以它在第三个位置。并且在最后一个 id 中没有匹配的单词,所以它不能显示。
我正在使用MATCH......AGAINST,我认为这很好。
【问题讨论】:
-
你有什么问题?
-
我无法得到这样的结果。请指导我怎样才能得到这样的结果。任何想法