Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2016-06-01 12:59:23
Original
1668 people have browsed it

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

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

 

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

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!