drop procedure if exists proc_name;
delimiter //
create procedure proc_name (in parameter integer)
begin
if parameter=0 then
select * from student order by no asc;
else
select * from student order by height asc;
end if;
end;
//
delimiter ;
call proc_name(0);
+--------+----------+--------+
| no | name | height |
+--------+----------+--------+
| 122654 | wangwu | 1.36 |
| 123654 | zhangsan | 1.56 |
| 129854 | lisi | 1.16 |
+--------+----------+--------+
call proc_name(5);
+--------+----------+--------+
| no | name | height |
+--------+----------+--------+
| 129854 | lisi | 1.16 |
| 122654 | wangwu | 1.36 |
| 123654 | zhangsan | 1.56 |
+--------+----------+--------+