sql语句中count(1)和count(字段名)的区别
在SQL语句中count函数是最常用的函数之一,count函数是用来统计表中记录数的一个函数
count(1)会统计 包括null值的所有符合条件的字段的条数
count(字段名)统计 非null值的所有符合条件的字段的条数
比如:
tb_source表中数据
count(1)统计当type=3时source_name的条数
select count(1) from tb_source where type=3
count(字段名)统计type=3时source_name的条数
select count(source_name) from tb_source where type=3
1