计算在mysql中的blob数据类型的列中具有特定字的行数 [英] Counting the number of rows that have a particular word in a column of blob data type in mysql

查看:141
本文介绍了计算在mysql中的blob数据类型的列中具有特定字的行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在mysql中有这样的表。列'file'的数据类型为blob。我需要计数在文件列中具有单词'lumia'和在'属性'列中具有单词'display'的行数。也就是说,这里是行1和3.所以输出必须是2.我如何在mysql中这样做?

I have a table like this in mysql. The datatype of column 'file' is blob. I need to count the number of rows which have the word 'lumia' in column 'file' and 'display' in column 'attribute'. That is, here the rows 1 and 3. so the output has to be 2. How can i do that in mysql?

行不需要计数两次。

  +------+----------------------------+------------+
  | slno | file                       | attribute  | 
  +------+----------------------------+------------+
  |    1 | 5inch 8mp lumia snapdragon | display    |
  |
  |    2 | 8mp galaxy samsung android | camera     | 
  |
  |    3 | nokia lumia red lumia      | display    |
  |
  |    4 | black samsung 8mp android  | camera     |
  |
  |    5 | lumia windows 8mp red      | model      |


推荐答案

除了如何计算

如果您需要获得总和,请尝试这样的

If you need to get the sum try something like this

SELECT SUM(IF(LOCATE(@searchthis, file),1,0)) AS Count_Sum FROM  `documents`;

排除 SUM()如下所述条件第三行中的单词lumia的多次出现不需要计数两次

Excluding the SUM() the results are like below as stated in condition "The multiple occurrence of the word lumia in 3rd row need not be counted twice"

这篇关于计算在mysql中的blob数据类型的列中具有特定字的行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆