mysql FULLTEXT 搜索多个单词
我从来没有真正听到过关于这个问题的直接答案,我只需要全文搜索几个包含多个单词名字姓氏"的列
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.
推荐答案
$sql = mysql_query("SELECT * FROM
patient_db WHERE
MATCH ( Name, id_number )
AGAINST ('+first_word +second_word +third_word' IN BOOLEAN MODE);");
如果你想进行精确搜索:
and if you want to do exact search:
$sql = mysql_query("SELECT *
FROM patient_db
WHERE MATCH ( Name, id_number )
AGAINST ('"exact phrase"' IN BOOLEAN MODE);");
相关文章