如何查询按相似性排序的记录?
例如.搜索"股票溢出"将返回
例如.搜索"LO"将返回:
LIKE 返回更好的结果,但对于长查询不返回任何内容,尽管存在类似的字符串
How can queries like
SELECT * FROM sometable WHERE somefield LIKE '%value%'
Run Code Online (Sandbox Code Playgroud)
be optimized?
The main issue here is the first wildcard which prevents DBMS from using index.
Edit: What is more, somefield value is solid string (not a piece of text) so fulltext search could not be performed.
如何使用全文搜索在MySQL中查询,以便我们可以获得如下的结果:
nited变得团结起来,而oogle得到谷歌
我们可以使用LIKE运算符: %nited and %oogle