[SQL]Select COUNT(*) and COUNT(1) and COUNT(‘rainmaker’) and COUNT(column)的差别

Select COUNT(*) and COUNT(1) and COUNT('rainmaker') and COUNT(column)的差别


请看以下的测试


create table a
(
c1 varchar(10),
c2 varchar(10)
)

insert a values('1', '1')
insert a values('2', '2')
insert a values(null, null)

select COUNT(*) from a
select COUNT(1) from a
select COUNT('rainmaker') from a
select COUNT(c1) from a

image

结论

COUNT(*) = COUNT(1) = COUNT('rainmaker') 可能不等于(如果该字段有null值的话) COUNT(column)