I notice one of my MySQL full text search result for multiple words doesnt seems correct. After some checking, i realize i don’t know how to do full text search for multiple words! LOL. This is because i use ONLY single words during testing. After go thru the MySQL documentation again, now i get a clear view of how to structure the SQL statement for full text search (multiple words)!
Here are some example for MySQL full text search for multiple words:-
Advertisements
- ‘”MySQL database”‘ – Find rows that contain the exact phrase “MySQL database”. (eg, rows that contain “MySQL database good” but NOT “MySQL excellent database”). Note that the double quote characters that enclose the phrase are operator characters that delimit the phrase.
SELECT * FROM articles WHERE MATCH (body) AGAINST ('"MySQL database"' IN BOOLEAN MODE);
- ‘tech blog’ – Find rows that contain at least contain one of the two words
SELECT * FROM articles WHERE MATCH (body) AGAINST ('tech blog' IN BOOLEAN MODE);
- ‘+mysql -mssql’ – Find rows that contain the word “mysql” but not “mssql”
SELECT * FROM articles WHERE MATCH (body) AGAINST ('+mysql -mssql' IN BOOLEAN MODE);
- ‘data*’ – Find rows that contain words such as “data”, “database” or “databases”.
SELECT * FROM articles WHERE MATCH (body) AGAINST ('data*' IN BOOLEAN MODE);
Hope these examples help you in MySQL full text search for multiple words 🙂
Related posts:
How to install SVN 1.6 on CentOS 5
WordPress: How to upload image using script?
How to split compressed file into smaller files in Linux / Mac
How to enable personal file sharing in Ubuntu 10.04
How to sort drop down - Admin Generator - Symfony 1.4
MySQL replication stop at Last Errno 1062
How to install apache, php, mysql with macport in Mac OS X
How to use apt to list available packages?
Share this with your friends:-
Hi,
how to search for All keywords, not just Any keyword or exact phrase with MATCH() AGAINST()?
and why is not working without BOOLEAN MODE?
tnx 🙂