試圖找出它爲什麼是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
-> //
請出示完整的代碼。 – Devart
@Devart:我已更新信息 – John