Home  >  Article  >  Database  >  如何使用MySQL查询某个列中相同值的数量统计_MySQL

如何使用MySQL查询某个列中相同值的数量统计_MySQL

WBOY
WBOYOriginal
2016-06-01 12:59:231665browse

数据现在是这样的,我想确定出type列中的news和image。。。。甚至以后有其他值,他们分别有多少个。

SELECT 
 type, 
 count(1) AS counts 
FROM 
 material 
GROUP BY 
 type

 

count(1),代表统计第一列,写上1 比写 *的效率高!

以上所述就是本文的全部内容了,希望大家能够喜欢。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn