CREATE PROCEDURE pro3(empName VARCHAR(30))
BEGIN
DECLARE empJob VARCHAR(30);
SELECT job into empJob FROM emp WHERE ename = empName;
if empJob is null then
set empJob = '普通员工';
END IF;
UPDATE emp set job = empJob where ename = empName;
SELECT * FROM emp where ename = empName;
end;
call pro3('阿卡丽')
思路
查询某个员工,当员工job为null时显示他是普通员工,首先是查询你要查询的员工的工作,如果工作是空,就把需要的要求填入进去,然后更新操作.