计算 MySQL 中某个单词在一行中的出现次数 [英] Count occurrences of a word in a row in MySQL

查看:27
本文介绍了计算 MySQL 中某个单词在一行中的出现次数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的网站制作一个搜索功能,该功能可以从数据库中查找相关结果.我正在寻找一种计算单词出现次数的方法,但我需要确保单词两侧都有单词边界(所以当我想要rip"时,我不会以triple"结尾).

I'm making a search function for my website, which finds relevant results from a database. I'm looking for a way to count occurrences of a word, but I need to ensure that there are word boundaries on both sides of the word ( so I don't end up with "triple" when I want "rip").

有人有什么想法吗?

人们误解了我的问题:

如何计算在一行中出现的次数?

How can I count the number of such occurences within a single row?

推荐答案

这不是关系型数据库擅长的事情,除非你可以使用全文索引,而且你已经说过你不能,因为你正在使用 InnoDB.我建议选择您的相关行并在您的应用程序代码中进行字数统计.

This is not the sort of thing that relational databases are very good at, unless you can use fulltext indexing, and you have already stated that you cannot, since you're using InnoDB. I'd suggest selecting your relevant rows and doing the word count in your application code.

这篇关于计算 MySQL 中某个单词在一行中的出现次数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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