如何通过mysql获取表中最流行的单词?
我有一个带有 BLOB 列的表。 我想做的是让它能够挑选出单词并按顺序列出它们。
例如,如果它包含:
- 鲍勃史密斯喜欢奶酪但喜欢阅读
- 查理喜欢巧克力牛奶
- 查尔喜欢漫画但也喜欢饼干
那么我会得到
- 喜欢
- 的
结果......这可能吗?如果可能的话如何?
我希望能够仅在 mysql 中完成此操作,但我也可以使用 php。
提前致谢, 肯尼
I've got a table with a BLOB column. What I want to do is get it to be able to pick out words and list them in order.
For example if it contained:
- Bob Smith likes cheese but loves reading
- Charlie likes chocolate milk
- Charl loves manga but also likes cookies
Then I would get
- likes
- loves
as a result... is this possible and if so how?
I'd like to be able to do it in just mysql alone, but I can use php as well.
Thanks in advance,
kenny
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我已经重新编写了我的代码,所以我不再需要这样做......标准设置似乎是不可能的
I've re-worked my code so I no longer need to do this... it seems impossible with standart setups
不要认为有任何内置的 MySQL 函数可以执行此操作,因此您可能最好使用 PHP 来使用
explode(' ', $myString)
或str_word_count( $myString, 1)
创建一个包含每个单词的数组。 然后循环遍历数组中的每个单词并对它们进行计数。Don't think there is any built in MySQL function to do this so you are probably best using PHP to do the work for you using either
explode(' ', $myString)
orstr_word_count($myString, 1)
to create an array containing each word. Then loop through each word in the array and count them.Sphinx Search (http://sphinxsearch.com/) 是一个在 mysql 中搜索全文的应用程序以及其他数据库和文件格式。 简而言之,它提供了与 mysql 表相关的搜索。
它的工具之一执行字数统计,下面是一个 bash 脚本,让它输出数据库中最流行的单词:
Sphinx Search (http://sphinxsearch.com/) is a application that does a lot around searching full text in mysql as well as other db's and file formats. In short, it offers search with relavence of mysql tables.
One of it's tools performs word counts, the following is a bash script to get it to output the most popular words in a database: