简单的 FULLTEXT 搜索

    SET @searchTerm= 'Database Programming';
 SELECT MATCH (Title) AGAINST (@searchTerm IN NATURAL LANGUAGE MODE) Score,
        ISBN, Author, Title 
   FROM book
  WHERE MATCH (Title) AGAINST (@searchTerm IN NATURAL LANGUAGE MODE)
  ORDER BY MATCH (Title) AGAINST (@searchTerm IN NATURAL LANGUAGE MODE) DESC;

给定一个名为 book 的表,其中包含名为 ISBN,‘Title’和’Author’的列,它会查找与'Database Programming'匹配的书籍。它首先显示最佳匹配。

为此,必须提供 Title 列上的全文索引:

ALTER TABLE book ADD FULLTEXT INDEX Fulltext_title_index (Title);