mysql> drop procedure if exists `addAge` $$ Query OK, 0 rows affected (0.00 sec) mysql> create procedure addAge(age int,fun varchar(10)) -> begin -> if fun='add' then -> select 'add'; -> else -> select 'j'; -> end if; -> end $$ Query OK, 0 rows affected (0.00 sec) mysql> call addAge(10,"add")$$ +-----+ | add | +-----+ | add | +-----+ 1 row in set (0.00 sec) Query OK, 0 rows affected (0.00 sec) mysql> call addAge(10,"jian")$$ +---+ | j | +---+ | j | +---+ 1 row in set (0.00 sec) Query OK, 0 rows affected (0.00 sec) mysql> show tables $$ +----------------+ | Tables_in_test | +----------------+ | web_stu | | web_student | +----------------+ 2 rows in set (0.00 sec) mysql> select * from web_stu $$ +--------+ | sex | +--------+ | male | | female | +--------+ 2 rows in set (0.01 sec) mysql> select * from web_student $$ +----+----------+------+------------+ | id | username | age | posttime | +----+----------+------+------------+ | 1 | d3aAB6 | 65 | 1478144500 | | 2 | lTaQ5h | 55 | 1478144505 | | 3 | uBFpCW | 40 | 1478144509 | | 4 | KeELzx | 42 | 1478144534 | | 5 | 1uHRl5 | 39 | 1478158277 | +----+----------+------+------------+ 5 rows in set (0.00 sec) mysql> create procedure p3(n int) -> select * from web_student where cid > n; -> end $$ Query OK, 0 rows affected (0.00 sec) mysql> create procedure p3(n int) -> begin -> select * from web_student where cid > n; -> end $$ ERROR 1304 (42000): PROCEDURE p3 already exists mysql> drop procedure if exists `p3` $$ Query OK, 0 rows affected (0.00 sec) mysql> create procedure p3(n int) -> begin -> select * from web_student where cid > n; -> end $$ Query OK, 0 rows affected (0.00 sec) mysql> call p3(3)$$ ERROR 1054 (42S22): Unknown column 'cid' in 'where clause' mysql> drop procedure if exists `p3` $$ Query OK, 0 rows affected (0.00 sec) mysql> create procedure p3(n int) -> begin -> select * from web_student where id > n; -> end $$ Query OK, 0 rows affected (0.00 sec) mysql> call p3(3)$$ +----+----------+------+------------+ | id | username | age | posttime | +----+----------+------+------------+ | 4 | KeELzx | 42 | 1478144534 | | 5 | 1uHRl5 | 39 | 1478158277 | +----+----------+------+------------+ 2 rows in set (0.00 sec) Query OK, 0 rows affected (0.02 sec) mysql> exit $$