用mysql搜索关键字
我应该使用什么来使用 mysql 搜索关键字?
我有一个单词,在查询中
wordless
something word something
someword some
else
other
wordother
thingword
我想输出其中包含该单词的所有内容,但输出就像第一个输出的行一样,即以单词作为第一个字母的行,例如
无字 - 将是首先,因为单词是单词“wordless”的第一个字符 以及要输出到第一个输出行的单词other,然后在它们之后输出某些单词某些单词等,每个包含名称单词的单词,但再次首先输出第一个字符处具有该单词的行。
编辑:
SELECT *,MATCH(add_songName) AGAINST('d' IN BOOLEAN MODE) as
scoreFROM 歌曲 WHERE MATCH(add_songName) AGAINST('d') ORDER BY
score DESC
,在这里我正在搜索 d 但它给了我一个错误 -
Can't find FULLTEXT index matching the column list SELECT *,MATCH(add_songName) AGAINST('d' IN BOOLEAN MODE) as `score` FROM songs WHERE MATCH(add_songName) AGAINST('d') ORDER BY `score` DESC
What should I use, to search for a keyword with mysql ?
I have a word and in the query I have
wordless
something word something
someword some
else
other
wordother
thingword
I want to output everything that has the word inside it, but the output to be like first outputed rows to be that rows with word as first letter on them, for example
wordless - will be the first because word are first characters of the word wordless
and the wordother to be outputed to to the first outputed rows, then after them to output something word something and etc, every word that contains the name word, but again to output first that rows that have the word at the first characters.
EDIT:
SELECT *,MATCH(add_songName) AGAINST('d' IN BOOLEAN MODE) as
scoreFROM songs WHERE MATCH(add_songName) AGAINST('d') ORDER BY
scoreDESC
, Here i'm searching for d but it gives me an error -
Can't find FULLTEXT index matching the column list SELECT *,MATCH(add_songName) AGAINST('d' IN BOOLEAN MODE) as `score` FROM songs WHERE MATCH(add_songName) AGAINST('d') ORDER BY `score` DESC
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试在MySQL中使用Levenshtein算法。
编辑匹配是衡量两个序列之间差异程度的度量,这里是字符串。默认情况下MySQL没有这个功能,但是你可以自己编写并添加一个。
请看一下这里的代码,并将该代码添加为 MySQL 中的系统函数,请参阅下面的示例,了解如何获取两个字符串的相似度。
请参阅:https://github.com/rakesh-sankar/工具/blob/master/MySQL/Levenshtein.txt
Try to use Levenshtein algorithm in MySQL.
Levenshtein matching is a metric for measuring the amount of difference between two sequence, here it is strings. By default MySQL does not have this function, but you can write and add one.
Please take a look at the code here and add that code as a system function in MySQL, please see the example below on how to get the similarity of two strings.
Please see: https://github.com/rakesh-sankar/Tools/blob/master/MySQL/Levenshtein.txt