php how to unit 2 fulltext search and order by date?
I want to make a fulltext search, there are 2 group search query, one search match word 'Harry' and 'potter', second search query only match word 'Rowling'. How to unit them and order dy date
? Then $query1 relevance is 70%
, $query1 relevance is 30%
? Thanks.
$query1 = "SELECT * FROM articles WHERE MAT开发者_运维知识库CH (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'
Both your queries select rows from the same table and the same columns set. What about 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)";
精彩评论