更新时间:2023-01-30 23:30:07
该行为是由于将输入参数命名为与列名相同而引起的,因此mysql无法区分列和where
子句中的参数.将输入参数重命名为param_ID
,它将返回带有请求的ID
值的记录.
The behaviour is caused by naming the input parameter same as the column name, therefore mysql cannot distinguish between the column and the parameter within the where
clause. Rename the input parameter to let's say param_ID
and it will return the record with the requested ID
value.
DELIMITER $$
CREATE PROCEDURE `buscarPaciente`(IN param_ID INT)
BEGIN
SELECT * FROM Paciente WHERE ID = param_ID LIMIT 1;
END
$$
DELIMITER ;