CREATE PROCEDURE `up40`(in raise int, in gender char(1))
begin
if(gender = 'M') then
update teste set wage = wage + raise where gender = 'M';
end if;
if(gender = 'F') then
update teste set wage = wage + raise where gender = 'F';
end if;
end;
答案 0 :(得分:1)
你可以尝试一下:
CREATE PROCEDURE `up40` (
IN raise INT,
IN genderParam CHAR (1)
)
BEGIN
UPDATE teste SET wage = wage + raise
WHERE gender = genderParam;
END;
尝试为变量使用不同的名称,以便区分列名和变量。
如果有条件,你也不需要那些。只需一个带有where子句的简单更新语句即可。