mysql FULLTEXT 搜索多个单词

mysql FULLTEXT search multiple words(mysql FULLTEXT 搜索多个单词)
本文介绍了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);");

这篇关于mysql FULLTEXT 搜索多个单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Difference between mt_rand() and rand()(mt_rand() 和 rand() 的区别)
Coalesce function for PHP?(PHP的合并函数?)
Fastest way to convert string to integer in PHP(在 PHP 中将字符串转换为整数的最快方法)
2 Column Mysql Date Range Search in PHP(PHP中的2列Mysql日期范围搜索)
mysql match against ~ example(mysql 匹配 ~ 示例)
How-to: Ranking Search Results(操作方法:对搜索结果进行排名)