Simple BOOLEAN search
suggest changeSET @searchTerm= '+Database +Programming -Java';
SELECT MATCH (Title) AGAINST (@searchTerm IN BOOLEAN MODE) Score,
ISBN, Author, Title
FROM book
WHERE MATCH (Title) AGAINST (@searchTerm IN BOOLEAN MODE)
ORDER BY MATCH (Title) AGAINST (@searchTerm IN BOOLEAN MODE) DESC;
Given a table named book with columns named ISBN, Title, and Author, this searches for titles that contain both Database and Programming and do not contain Java. In boolean mode a bare word is optional. + requires it and - excludes it.
For this to work, a fulltext index on the Title column must be available:
ALTER TABLE book ADD FULLTEXT INDEX Fulltext_title_index (Title);
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents