MySQL SUM() 函数将返回 0,而不是 NULL,并在获取字符类型列作为其参数时发出警告。以下示例将使用名为“社交”的表中的数据进行说明 -
示例
mysql> Select * from Social;
+------+-------+
| Id | Name |
+------+-------+
| 100 | Rahul |
+------+-------+
1 row in set (0.00 sec)
mysql> Select SUM(Name) From Social;
+-----------+
| SUM(Name) |
+-----------+
| 0 |
+-----------+
1 row in set, 1 warning (0.00 sec)