mysql WHERE MATCH AGAINST

微笑、不失礼 提交于 2019-12-20 02:59:06

问题


I am having a problem with a mysql and MATCH AGANIST.

I got this row in my database :

1:{Czy jesteśmy tutaj sami};2:{Margit Sanoemo}

I want to find this by following query :

SELECT * FROM data WHERE MATCH (params) AGAINST('*argi*' IN BOOLEAN MODE)

but I got an empty row.

However with this query :

SELECT * FROM dataWHERE MATCH (params) AGAINST('margi*' IN BOOLEAN MODE)

I get want I want.

Can you help me with double ** in params ? AGAINST('*argi*' IN BOOLEAN MODE)


回答1:


+

A leading plus sign indicates that this word must be present in every row returned.

-

A leading minus sign indicates that this word must not be present in any row returned.

< >

These two operators are used to change a word’s contribution to the relevance value that is assigned to a row. The < operator decreases the contribution and the > operator increases it. See the example below.

( )

. Parentheses are put round sub-expressions to give them higher precedence in the search.

~

A leading tilde acts as a negation operator, causing the word’s contribution to the row relevance to be negative. It’s useful for marking noise words. A row that contains such a word will be rated lower than others, but will not be excluded altogether, as it would be with the minus operator.

*

*An asterisk is the truncation operator. Unlike the other operators, it is appended to the word, or fragment, not prepended.*

Double quotes at the beginning and end of a phrase, matches only rows that contain the complete phrase, as it was typed.




回答2:


Do not embed variables into double-quoted strings and you are set:

SELECT * FROM " . $table . WHERE MATCH (message) AGAINST ('%" . $string . "%' IN BOOLEAN MODE)



来源:https://stackoverflow.com/questions/10931701/mysql-where-match-against

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!