How to count the number of occurrences of a particular word in a MySQL blob text?

半世苍凉 提交于 2019-12-24 23:33:29

问题


I have stored the contents of a text file in a MySQL table as a blob. I want to count the number of occurrences of a particular word from that text.

Is there any way I can do that?


回答1:


Try this

SET @searchthis="lumia"; 
SELECT  CAST((LENGTH(`documents`.`file`) - 
              LENGTH(REPLACE(`documents`.`file`, @searchthis, ""))) /
              LENGTH(@searchthis) AS UNSIGNED
            ) AS searchthis_count
    FROM  documents ;


来源:https://stackoverflow.com/questions/29454011/how-to-count-the-number-of-occurrences-of-a-particular-word-in-a-mysql-blob-text

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!