From d494b911e0cceead86946b8d2ef25ea726904eb6 Mon Sep 17 00:00:00 2001 From: smallkun Date: Fri, 21 Feb 2025 11:42:10 +0800 Subject: [PATCH] Auto commit --- 2208/天天乐学考试答案/MySQL练习(一).md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/2208/天天乐学考试答案/MySQL练习(一).md b/2208/天天乐学考试答案/MySQL练习(一).md index 4f5438f..8641bc4 100644 --- a/2208/天天乐学考试答案/MySQL练习(一).md +++ b/2208/天天乐学考试答案/MySQL练习(一).md @@ -60,5 +60,23 @@ WHERE money >= 5000 AND money <= 8000; #6 + +#10 存储过程 +DELIMITER $$ #改变代码结束符 +DROP PROCEDURE IF EXISTS pro_GetTopSalary;#创建存储过程之前先删除 +#设置存储过程名,传入传出参数名和数据类型 +CREATE PROCEDURE pro_GetTopSalary(IN in_did CHAR(10), OUT out_ename VARCHAR(30)) +BEGIN + #连接查询+排序+分页 + SELECT e.ename INTO out_ename + FROM t_employee e, t_salary s + WHERE e.eid = s.eid AND e.did = in_did + ORDER BY s.money DESC + LIMIT 1; +END $$ +DELIMITER ; +#调用存储过程 传入用户变量接收传出数据并使用打印出来 +CALL pro_GetTopSalary('d0001', @result); +SELECT @result; ```