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

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

问题描述

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

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天全站免登陆