问题
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