在mysql中显示count()的特定字符并显示它

时间:2014-10-26 15:08:08

标签: mysql mysqli phpmyadmin

我有这个代码试图显示用户名的计数,其中描述值为'是'仅

Mycode:

SELECT DISTINCT username, COUNT(description) 
FROM products GROUP BY username


*which I trying to add//WHERE description = 'Yes'

但它显示并计算了描述中的所有数据。

我只想显示带有'是'

值的描述计数

任何人都可以帮助我?

2 个答案:

答案 0 :(得分:1)

尝试此查询

 SELECT count(*),username
 FROM products
  WHERE
  description LIKE '%Yes%'
  or
 description LIKE '%yes%'
 GROUP BY username

答案 1 :(得分:0)

这应该为你做....

SELECT count(*),username
FROM products 
WHERE description = 'yes'
GROUP BY username