试图弄清楚为什么它是NULL。我期待 7 被打印出来。
mysql> set @total = 0;
Query OK, 0 rows affected (0.00 sec)
mysql> call getAuthorCount(@total);
+------------------------+
| count(distinct author) |
+------------------------+
| 7 |
+------------------------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.02 sec)
mysql> select @total as totalauthors;
+--------------+
| totalauthors |
+--------------+
| NULL |
+--------------+
步骤,
mysql> create procedure getAuthorCount(out authorcount int)
-> begin
-> select count(distinct author) from libbooks;
-> end
-> //