我在MySQL存储过程中有问题
表tbl_teachers:
tbl_teachers
id dat_teacher_doj fk_int_dept_id 1 1982-01-10 1 2 1979-09-01 1 3 1981-10-13 1
在这里,我需要创建一个存储过程来找出教师的加入日期,如果是星期一,则应该显示星期一,否则应该显示``平日’‘?我需要像这样的答案:
呼叫检查日期(1982-01-10)->工作日
只是CASE借助DAYNAME
CASE
DAYNAME
SELECT id, dat_teacher_doj, CASE DAYNAME(dat_teacher_doj) WHEN 'Monday' THEN 'Monday' ELSE 'Weekday' END FROM tbl_teachers
程序:这将在工作localhost phpmyadmin以及workbench
localhost phpmyadmin
workbench
CREATE PROCEDURE `GetWeekDay`(IN `paramDate` DATE) NO SQL SELECT CASE DAYNAME(paramDate) WHEN 'Monday' THEN 'Monday' ELSE 'Weekday' END AS 'WkDy'
称呼
CALL `GetWeekDay`('2015-08-03');