Home:ALL Converter>mysql FULLTEXT search multiple words

mysql FULLTEXT search multiple words

Ask Time:2011-07-16T20:20:12         Author:Jeff Voss

Json Formatter

I've never really heard a straight answer on this one, I just need to FULLTEXT search a couple columns with multiple words "Firstname Lastname"

$sql = mysql_query("SELECT * FROM 
                    patient_db 
                    WHERE MATCH ( Name, id_number )
                    AGAINST ('% $term %' IN BOOLEAN MODE);");

But it fails to run the query if I enter more than one word here.

Author:Jeff Voss,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/6717312/mysql-fulltext-search-multiple-words
Vineet1982 :

$sql = mysql_query(\"SELECT * FROM \n patient_db WHERE \n MATCH ( Name, id_number ) \n AGAINST ('+first_word +second_word +third_word' IN BOOLEAN MODE);\");\n\n\nand if you want to do exact search:\n\n$sql = mysql_query(\"SELECT * \n FROM patient_db \n WHERE MATCH ( Name, id_number ) \n AGAINST ('\"exact phrase\"' IN BOOLEAN MODE);\");\n",
2011-07-16T12:27:30
yy