是否有用于计算字符串在另一个字符串或列中出现的次数的 MySQL 函数?基本上我想要:
Is there a function for MySQL that will count the number of times a string occurs in another string or column? Basically I want:
SELECT
SUB_COUNT('my word', `my_column`) AS `match_count`
FROM `table`
谢谢!
我需要知道字符串在 SELECT
中的每一行的列中出现多少次.
I need to know how many times the string appears in a column for each row in a SELECT
.
一个明显但不可扩展的方式是这样的
An obvious but unscalable way is like this
(LENGTH(`my_column`) - LENGTH(REPLACE(`my_column`, 'my word', '')))/LENGTH('my word')
您是否调查过全文搜索在 MySQL 中?
Have you investigated Full Text search in MySQL?
这篇关于SQL函数获取字符串在列中出现的次数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!