From bf07420a5e5e0f60a35ce36a2f09527f4d5b3bf4 Mon Sep 17 00:00:00 2001 From: smallkun Date: Thu, 20 Mar 2025 16:33:58 +0800 Subject: [PATCH] Auto commit --- 2208/存储过程练习题.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/2208/存储过程练习题.md b/2208/存储过程练习题.md index ed0b804..07e1f53 100644 --- a/2208/存储过程练习题.md +++ b/2208/存储过程练习题.md @@ -207,6 +207,21 @@ CALL add_employee('李泽龙', 6666, '2025-3-20', 1, 1); 创建一个存储过程 `get_employee_details`,接受员工ID作为参数,返回该员工的姓名、工资、部门名称和职位名称。 +```sql +DELIMITER $$ +DROP PROCEDURE IF EXISTS get_employee_details; +CREATE PROCEDURE get_employee_details(IN emp_id INT) +BEGIN + SELECT e.emp_name, e.salary, d.dept_name, j.job_title + FROM employee e, department d, job j + WHERE e.emp_id = emp_id AND e.dept_id = d.dept_id AND e.job_id = j.job_id; +END $$ +DELIMITER ; +CALL get_employee_details(1); +``` + + + #### 练习题 13: 查询部门最高工资 创建一个存储过程 `get_department_max_salary`,接受部门ID作为参数,返回该部门的最高工资。