DELIMITER $$
USE `test`$$
DROP PROCEDURE IF EXISTS `liangzi`$$
CREATE DEFINER=`admin`@`%` PROCEDURE `liangzi`(IN i INT)
xiaoliangzi:BEGIN
IF i=1 THEN
SELECT 1;
LEAVE xiaoliangzi;
SELECT 'BBS';
ELSEIF i=2 THEN
SELECT 2;
LEAVE xiaoliangzi;
SELECT 'BBS';
ELSE
SELECT 3;
SELECT 'BBS';
END IF;
SELECT 'BLOG.51CTO.COM';
END$$
DELIMITER ;
-- ------------------------------------------
mysql> call liangzi(2);
+---+
| 2 |
+---+
| 2 |
+---+
1 row in set (0.00 sec)
-- ------------------------------------------
mysql> call liangzi(3);
+---+
| 3 |
+---+
| 3 |
+---+
1 row in set (0.00 sec)
+-----+
| BBS |
+-----+
| BBS |
+-----+
1 row in set (0.00 sec)
+----------------+
| BLOG.51CTO.COM |
+----------------+
| BLOG.51CTO.COM |
+----------------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
-- ------------------------------------------
mysql> call liangzi(4);
+---+
| 3 |
+---+
| 3 |
+---+
1 row in set (0.00 sec)
+-----+
| BBS |
+-----+
| BBS |
+-----+
1 row in set (0.00 sec)
+----------------+
| BLOG.51CTO.COM |
+----------------+
| BLOG.51CTO.COM |
+----------------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)