MYSQL FULLTEXT搜索不适用于hypen' - '和加'+' [英] MYSQL FULLTEXT search does not work with hypen '-' and plus '+'
问题描述
问题:我使用MYSQL和PHP最新版本。我们在MYSQL FULLTEXT搜索中遇到了这个问题。它不适用于hypen( - )和plus(+)字符。
示例:1
在行业表,'industry_size'字段具有以下值:
1. 1
2. 2 - 9
3。 10 - 15
如果我使用搜索词 2 - 9
,它将显示空的结果,但正确的答案是 2 - 9
。
例如: strong>
在用户表中,'phone_number'字段具有以下值:
1. 9856237845
2 。+91 8945785698
3. +91 7489569878
如果我使用搜索词 +91 89
,它会显示空的结果,但正确的答案是 +91 8945785698
。
<请注意。提前致谢。
您需要使用*。 文档说:
星号用作截断(或通配符)运算符。与其他操作符
不同,它应该被附加到要影响的单词上。
如果以*运算符之前的单词开头,则匹配单词。
试试这个:
MATCH(field)AGAINST(+ 91 89 *IN BOOLEAN模式)
或者您可以使用Binary运算符
其中BINARY your_column = BINARY 9
Issue: I am using the MYSQL and PHP latest versions. We are facing the issue in the MYSQL FULLTEXT search. It does not work with the hypen(-) and plus(+) characters.
Example:1 In the industry table, 'industry_size' field have the following values:
1. 1 2. 2 - 9 3. 10 - 15
If i am using the search term 2 - 9
, it will show the empty result but the correct answer is 2 - 9
.
Example:2 In the user table, 'phone_number' field have the following values:
1. 9856237845 2. +91 8945785698 3. +91 7489569878
If i am using the search term +91 89
, it will show the empty result but the correct answer is +91 8945785698
.
Kindly advise. Thanks in advance.
You need to use *. The documentation says:
The asterisk serves as the truncation (or wildcard) operator. Unlike the other operators, it should be appended to the word to be affected. Words match if they begin with the word preceding the * operator.
Try this:
MATCH(field) AGAINST("+91 89*" IN BOOLEAN MODE)
or you can use Binary operator
where BINARY your_column = BINARY "2-9"
这篇关于MYSQL FULLTEXT搜索不适用于hypen' - '和加'+'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!