count(1)与count(*)区别
count(1): 统计数量时都可以统计值为NULL或null
count(列名): 不统计值为NULL或者null
举例:下表名假设为 table
id | type |
1 | 2 |
2 | null |
3 |
select count(1) from table
结果:3
select count(type) from table
结果:2
select count(id) from table
结果:3
count(1): 统计数量时都可以统计值为NULL或null
count(列名): 不统计值为NULL或者null
举例:下表名假设为 table
id | type |
1 | 2 |
2 | null |
3 |
select count(1) from table
结果:3
select count(type) from table
结果:2
select count(id) from table
结果:3