mysql 存储过程 局部变量赋值给where 查询无结果 数据库有值 5
createproceduresp_search_employee3(inp_departint)begindeclaretmpchar(4);casep_departw...
create procedure sp_search_employee3(in p_depart int)
begin
declare tmp char(4);
case p_depart
when 1 then
set tmp = '研究部';
when 2 then
set tmp = 'IT部';
else
set tmp = '经理部';
end case;
select fname,lname from employee where depart = tmp;
end
//
call sp_search_employee3(1);
查询结果为空
select fname,lname from employee where depart = concat(tmp);
也没有结果
直接查询
select fname,lname from employee where depart = '研究部';
有两条结果 展开
begin
declare tmp char(4);
case p_depart
when 1 then
set tmp = '研究部';
when 2 then
set tmp = 'IT部';
else
set tmp = '经理部';
end case;
select fname,lname from employee where depart = tmp;
end
//
call sp_search_employee3(1);
查询结果为空
select fname,lname from employee where depart = concat(tmp);
也没有结果
直接查询
select fname,lname from employee where depart = '研究部';
有两条结果 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |