CREATE DEFINER=`root`@`%` PROCEDURE `sp_search_dir`(
IN name varchar(50),
OUT employeeId varchar(50) ,
OUT employeeName varchar(50)
)
BEGIN
-- First : working ---
SELECT EAE.id INTO employeeId , EAE.name INTO employeeName
FROM employeesDB.employee AS EAE
WHERE EAE.f_name LIKE CONCAT('%', name , '%');
-- Second Working ---
SELECT EAE.id INTO employeeId , EAE.name INTO employeeName
FROM employeesDB.employee AS EAE
WHERE EAE.f_name LIKE CONCAT('%', name , '%');
-- Third NOT working getting syntax ERROR why i am not able to set two
OUT variable in one select
SELECT
EAE.id INTO employeeId ,
EAE.name INTO employeeName
FROM employeesDB.employee AS EAE
WHERE EAE.f_name LIKE CONCAT('%', name , '%');
END
我无法在存储过程中的单个选择查询中设置多出值以获取ID和员工名,我必须调用两个选择查询,而我想在一个查询中提取结果。
最佳答案
您弄错了SELECT ... INTO语法。
一定是:
SELECT EAE.id, EAE.name
INTO employeeId, employeeName
FROM employeesDB.employee AS EAE
WHERE EAE.f_name LIKE CONCAT('%', name , '%');
关于mysql - 如何从单个“从存储过程中选择查询”设置多个Out变量值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49645655/