php如何通过日期单元2全文搜索和订购?

时间:2011-04-09 08:07:51

标签: php mysql full-text-search

我想进行全文搜索,有2个组搜索查询,一个搜索匹配单词'哈利'和'波特',第二个搜索查询只匹配单词'罗琳'。如何统一他们和order dy date?那么$query1 relevance is 70%$query1 relevance is 30%?感谢。

$query1 = "SELECT * FROM articles WHERE MATCH (title,content) AGAINST ('+Harry +potter' IN BOOLEAN MODE)";//all the articles both match word 'Harry' and 'potter'
$query2 = "SELECT * FROM articles WHERE MATCH (title,content) AGAINST ('+Rowling' IN BOOLEAN MODE)";//all the articles macth 'Rowling'

1 个答案:

答案 0 :(得分:0)

您的查询都会从同一个表中选择行并设置相同的列。 UNION怎么样?

$query = "SELECT * FROM articles WHERE MATCH (title,content) AGAINST ('+Harry +potter' IN BOOLEAN MODE)
UNION
SELECT * FROM articles WHERE MATCH (title,content) AGAINST ('+Rowling' IN BOOLEAN MODE)";