SET
variables 指定變數@
標示變數名稱SET @p=100, @q=5;
SELECT @p AS Price, @q AS Qty, @p*@q AS Amount;
SELECT @p:=200 AS Price, @q:=6 AS Qty, @p*@q AS Amount;
PREPARE
定義 statementPREPARE stmt1 FROM 'SELECT ?*10';
自定名稱 stmt1
為 prepared statement 。
SET
(指定值)SET @x=3;
EXECUTE
執行 prepared statementEXECUTE stmt1 USING @x;
PREPARE stmt2 FROM 'SELECT ? AS Price, ? AS Discount, ?*? AS Selling';
SET @p=100,@d=0.8;
EXECUTE stmt2 USING @p,@d,@p,@d;
SET @p=200;
EXECUTE stmt2 USING @p,@d,@p,@d;
SET @d=0.69;
EXECUTE stmt2 USING @p,@d,@p,@d;
更新日期: