Stu*_*tLC 10
他们是一样的。这在Stackoverflow和这里经常被问到
count(*), count(0), count(1), count(-1)
Run Code Online (Sandbox Code Playgroud)
都返回计数。
事实上,在SQL Server 中,甚至不计算表达式。
编辑事实上,在SQL服务器,一个COUNT(ALL ...)
常量表达式不会出现在所有被评估,但是,一个COUNT(DISTINCT ...)
是*。
例如
select count(ALL 1/0) from xyz; -- Succeeds
Run Code Online (Sandbox Code Playgroud)
但
select count(DISTINCT 1/0) from xyz; -- Divide by Zero
Run Code Online (Sandbox Code Playgroud)
并且至少有一个例外是 NULL
select count(1) from xyz; -- Operand data type void type is invalid for count operator.
Run Code Online (Sandbox Code Playgroud)
count(1/0)
无论行数如何,MySQL 中的 FWR 都返回 0。