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;
Given a table named book
with columns named ISBN
, 'Title', and 'Author', this finds books matching the terms 'Database Programming'
. It shows the best matches first.
For this to work, a fulltext index on the Title
column must be available:
ALTER TABLE book ADD FULLTEXT INDEX Fulltext_title_index (Title);