SQL-在文本中查找完整的单词 [英] SQL - Find complete word in text

查看:222
本文介绍了SQL-在文本中查找完整的单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MySql DB的一个表中有一个文本列. 我想获取在文本列中具有特定单词的所有记录. 例如:

I have a text column in one of my tables in a MySql DB. i want to get all the records that have a specific word in the text column. for example:

ID,BIO
1, "i am a cto"
2, "i am a cto/developer"
3, "cto"
4, "i am a cto_developer"
5, "ctools"

在这种情况下,当搜索"cto"时,我希望查询返回记录1,2,3,4而不是5.

In this case, when searching for "cto" I want the query to return records 1,2,3,4 but not 5.

有什么想法吗?

p.s.我希望它不区分大小写

p.s. I want it to be case insensitive

推荐答案

您可能想使用 REGEXP 将正则表达式指定为搜索单词.您应该查看此问题(和答案),以了解如何使用REGEXP查找单词

You may want to look into using full text indexing depending on the amount of data you are using. Otherwise, you can use REGEXP to specific a regular expression to search for the word. You should see this question (and answer) for a way of using REGEXP to find words.

这篇关于SQL-在文本中查找完整的单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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