mysql 在表列中搜索具有不同顺序的字符串 [英] mysql Search a string in table column having different order

查看:47
本文介绍了mysql 在表列中搜索具有不同顺序的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 mysql 表中有一个列有像迪拜丽兹酒店阿拉伯联合酋长国"这样的字符串如果搜索字符串是迪拜 rit"或阿拉伯联合酋长国 rit"或rit dubai",我想选择此列如果单词按任何顺序排列,我想选择此列,因为我可以看到它有单词.我尝试使用 mysql 'like' 和 mysql FULLTEXT 搜索,但我无法执行获得准确的结果

i have a column in mysql table having strings like 'dubai the-ritz hotel united arab emirates' i want to select this column if the search string is 'dubai rit' or 'united arab emirates rit' or 'rit dubai' if words are in any order i want to select this column as i can see it has the word. i tried using mysql 'like' and mysql FULLTEXT search but i am unable to perform the get the accurate results

SELECT * FROM `table`  where SearchString like 'dubai rit'

select * from table WHERE MATCH(SearchString) AGAINST('dubai rit' IN BOOLEAN MODE )

请提供任何帮助.

推荐答案

您将需要使用 * 来搜索部分单词:

You will need to use * to search partial words:

..
AGAINST('+dubai* +rit*' IN BOOLEAN MODE )

您可以在用于查询 MySql 的任何编程语言中的每个单词中添加 *.

You can add * to every word from whatever programming language you're using to query MySql.

PS:MySql 只允许前缀,即只能在字尾加*.

PS: MySql only allows prefix, means you can only add * at the end of the word.

参考:部分 *

这篇关于mysql 在表列中搜索具有不同顺序的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆