一尘不染

mysql FULLTEXT搜索多个单词

mysql

我从来没有真正听到过关于这个问题的直接答案,我只需要FULLTEXT搜索包含多个单词“ Firstname Lastname”的几列

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

但是,如果我在此处输入多个单词,它将无法运行查询。


阅读 357

收藏
2020-05-17

共1个答案

一尘不染

$sql = mysql_query("SELECT * FROM 
         patient_db WHERE 
         MATCH ( Name, id_number ) 
         AGAINST ('+first_word +second_word +third_word' IN BOOLEAN MODE);");

如果要进行精确搜索:

$sql = mysql_query("SELECT * 
                  FROM patient_db 
                  WHERE MATCH ( Name, id_number ) 
                  AGAINST ('"exact phrase"' IN BOOLEAN MODE);");
2020-05-17