2011-04-09 63 views
0

我想做一個全文搜索,有2個組搜索查詢,一個搜索匹配詞'Harry'和'potter',第二個搜索查詢只匹配單詞'Rowling'。如何將它們和order dy date?那麼$query1 relevance is 70%$query1 relevance is 30%?謝謝。php如何以單元2全文搜索並按日期排序?

$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' 
+0

@Charles,如何將'SELECT FROM LEFT JOIN ON WHERE'和SELECT FROM MATCH AGAINST'結合起來 – 2011-04-09 08:18:45

回答

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)";