但是,如果您只是使用SELECT * FROM testtableWHERE MATCH (sentence)AGAINST ('ISBN number on site');然后,MySQL将不仅返回具有您要查找的值的记录,而且还会返回仅包含某些单词且以不同顺序排列的记录.您显示的那张可能是排名最高的那张之一,但不能保证它会是排名最高的那张.您可能要使用布尔全文搜索并在每个搜索词前添加+,以强制MySQL仅返回所有存在搜索词的记录:SELECT * FROM testtableWHERE MATCH (sentence)AGAINST ('+ISBN +number +on +site' IN BOOLEAN MODE);但是,on应该是一个停用词(它在默认的提示词列表中),或者应该短于最小单词长度,因此应从搜索表达式中省略(您将不会获得任何结果): SELECT * FROM testtableWHERE MATCH (sentence)AGAINST ('+ISBN +number +site' IN BOOLEAN MODE);我知道这需要更改搜索表达式,但是使用MySQL的内置功能可以使您获得最佳结果.替代方法是使用其他全文本搜索引擎,例如 sphinx 为您执行搜索.search term=['ISBN number on site']the variable(column): sentence, in MySQL table. It consist many different sentence.the sentence I want to look for is"The AutoLink feature comes with Google's latest toolbar and provides links in a webpage to Amazon.com if it finds a book's ISBN number on the site."However, When I use the following statement:SELECT * FROM testtablewhere Sentence like "%ISBN number on site%" ;I am not able to get the result. This is because the search term("ISBN number on site") is lack of one word("the") compare with the sentence.How to change my statement in order to get the sentence I want? thanks.Assume that We do not change the search term=['ISBN number on site'] 解决方案 This is not a simple question. Your best bet is to use some type of fulltext search. Fulltext search can be configured to have stopwords (words that are omitted from search - like the word the) and can have a minimum word length limit as well (words with less than certain characters long are also omitted from the search.However, if you simply useSELECT * FROM testtableWHERE MATCH (sentence)AGAINST ('ISBN number on site');Then MySQL will return not just the record with the value you were looking for, but the records that have some of the words only, and in different order. The one you showed will probably be one of the highest ranking one, but there is no guarantee that it will be highest ranked one.You may want to use Boolean fulltext search and prepend + to every search word to force MySQL to return those records only that have all the search words present:SELECT * FROM testtableWHERE MATCH (sentence)AGAINST ('+ISBN +number +on +site' IN BOOLEAN MODE);But, on should either be a stopword (it is on the default stipword lists) or should be shorter that the minimum word length, so should be omitted from the search expression (you will not get back any results):SELECT * FROM testtableWHERE MATCH (sentence)AGAINST ('+ISBN +number +site' IN BOOLEAN MODE);I know that this requires alteration of the search expression, however this will get you the best results using MySQL's built-in functionality.The alternative is to use other fulltext search engines, such as sphinx to perform the search for you. 这篇关于如何使用模糊查找在SQL中查找句子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-14 23:37