一、创建存储过程实现传入用户名和密码,插入到admin表中
create procedure test_pro(in username varchar(20),in loginpw varchar(20))begininsert into admin(admin.username,password)values(username,loginpw);end
二、创建存储过程实现传入女神编号,返回女神名称和女神电话
create procedure test_pro1(in id int,out name varchar(20),out phone varchar(20))
begin
select b.name,b.phone into name,phone
from beauty b
where b.id=id;
end
三、创建存储存储过程或函数实现传入两个女神生日,返回大小
create procedure test_pro3(in b1 datetime,in b2 datetime,out result int)
begin
select datediff(b1,b2) into result;
end
四、创建存储过程或函数实现传入一个日期,格式化成xx年xx月xx日并返回
create procedure test_pro4(in mydate datetime,out strDate varchar(50))
begin
select date_format(mydate,'%y年%m月%d日') into strDate;
end
call test_pro4(now(),@str);
select @str;
五、创建存储过程或函数实现传入女神名称,返回:女神 and 男神 格式的字符串
如 传入 :小昭
返回: 小昭 AND 张无忌
create procedure test_pro5(in beautyName varchar(20),out str varchar(50))
begin
select concat(beautyName,'and',ifnull(boyName,'null'))into str
from boys bo
right join beauty b on b.boyfriend_id=bo.id
where b.name=beautyName;
end
call test_pro5('小昭',@str);
select @str;
六、创建存储过程或函数,根据传入的条目数和起始索引,查询beauty表的记录
create procedure test_pro6(in startIndex int,in size int)
begin
select * from beauty limit startIndex,size;
end
call test_pro6(2,2);
