mysql> create procedure p4()
-> begin
-> declare age int default 18;
-> if age >= 18 then
-> select "已成年";
-> else
-> select "未成年";
-> end if;
-> end$
Query OK, 0 rows affected (0.00 sec)
mysql> call p4
-> $
+-----------+
| 已成年 |
+-----------+
| 已成年 |
+-----------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
mysql>