即使在记录中有NULL值的情况下,为什么count(column)和count(*)返回相同的输出?

时间:2019-05-22 05:45:37

标签: mysql count

我有一个名为test的示例表,该表在名为mark的列之一中包含一个null值。该表有8条记录。当我运行以下查询时:

select count(marks) from test;

我得到7,这很好,因为忽略null值。由于该表有8条记录,因此count(*)给我8条记录。但是令人困惑的是,当我同时在下面运行这两个记录时:

select count(marks),count(*) from test;

我得到两个的输出8。为什么计数(标记)没有忽略此处的null值?

样品表:

enter image description here

1 个答案:

答案 0 :(得分:1)

这是Workbench 8.0.15中的错误。它已在Workbench 8.0.16中得到纠正。更新可以解决问题。