显示“select”语句两次的 MySQL 过程
为了理解,我们创建一个存储过程。在这里,我们在存储过程中有 2 个 select 语句 −
mysql> DELIMITER // mysql> CREATE PROCEDURE select_statement() -> BEGIN -> SELECT "HI" AS `FIRST VALUE`; -> SELECT "HELLO" AS `SECOND VALUE`; -> END -> // Query OK, 0 rows affected (0.09 sec) mysql> DELIMITER ;
使用 CALL 命令调用存储过程 −
mysql> CALL select_statement();
这将产生以下输出 −
+-------------+ | FIRST VALUE | +-------------+ | HI | +-------------+ 1 row in set (0.00 sec) +--------------+ | SECOND VALUE | +--------------+ | HELLO | +--------------+ 1 row in set (0.01 sec) Query OK, 0 rows affected (0.01 sec)
广告