Knowledge Walls
John Peter
Pune, Maharashtra, India
MATCH.. AGAINST.. FULL TEXT Search and Result Ordered by more relevance
3549 Views
MYSQL Query example's
# match text and order of the result by search string match count relevance.
SELECT *,
       MATCH (title,content) AGAINST ('search words') AS relevance
FROM
       USERS
WHERE
       MATCH (title,content) AGAINST ('search words')
ORDER BY
       relevance DESC;


# match with title and content but order of the result is title_relevance and then title with content relevance
SELECT *,
       MATCH (title,content) AGAINST ('search words') AS relevance,
       MATCH (title) AGAINST ('search words') AS title_relevance
FROM
       USERS
WHERE
       MATCH (title,content) AGAINST ('search words')
ORDER BY
       title_relevance DESC,
       relevance DESC;
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details