Count occurrences of a word in a row in MySQL(计算 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 中某个单词在一行中的出现次数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:计算 MySQL 中某个单词在一行中的出现次数
基础教程推荐
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
- 在多列上分布任意行 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- oracle区分大小写的原因? 2021-01-01
