Home  >  Article  >  Database  >  count(*) 和count(字段名)的区别_MySQL

count(*) 和count(字段名)的区别_MySQL

WBOY
WBOYOriginal
2016-06-01 13:49:011339browse

bitsCN.com

以前没有注意两者的区别,看博客园的文章,还真引起了我的注意。

数据测试:见图

sql 语句见分晓:

SELECT COUNT(*) c1 ,COUNT(ADDRESS) c2 FROM test

显而易见,count(*)统计的是结果集的总条数,count(字段名)统计的是该字段值不为null的总条数

bitsCN.com
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