From a546c2f47cd9ab1edd616abbfbabf282f8806dd2 Mon Sep 17 00:00:00 2001 From: smallkun Date: Fri, 21 Feb 2025 11:47:48 +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 8641bc4..ba84b72 100644 --- a/2208/天天乐学考试答案/MySQL练习(一).md +++ b/2208/天天乐学考试答案/MySQL练习(一).md @@ -60,6 +60,24 @@ WHERE money >= 5000 AND money <= 8000; #6 +#9 触发器 +DELIMITER $$ +DROP TRIGGER IF EXISTS tri_updateGroup; +CREATE TRIGGER tri_updateGroup +BEFORE UPDATE ON t_employee +FOR EACH ROW +BEGIN + IF NEW.age != OLD.age THEN + IF NEW.age<30 THEN + SET NEW.groups = '青年'; + ELSEIF NEW.age<50 THEN + SET NEW.groups = '中年'; + ELSE + SET NEW.groups = '老年'; + END IF; + END IF; +END $$ +DELIMITER ; #10 存储过程 DELIMITER $$ #改变代码结束符