在 MySQL 儲存過程中執行數學運算?
讓我們建立一個儲存過程。此處,我們正在計算 amount*quantity,即實現數學運算 −
mysql> delimiter // mysql> create procedure calculation_proc(amount int,quantity int) begin select amount,quantity,(amount*quantity) as Total; end // Query OK, 0 rows affected (0.00 sec) mysql> delimiter ;
現在,你可以使用 call 命令呼叫儲存過程 −
mysql> call calculation_proc(250,3);
這將生成以下輸出 −
+--------+----------+-------+ | amount | quantity | Total | +--------+----------+-------+ | 250 | 3 | 750 | +--------+----------+-------+ 1 row in set (0.00 sec) Query OK, 0 rows affected (0.00 sec)
廣告
資料結構
網路
資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
JavaScript
PHP