我试图通过存储过程取出一个字段,我使用了以下查询.我的目标是获取多行,但只有当存在一行时才能成功执行结果.否则它会返回错误,如下所述.
MYSQL查询
delimiter ;;
drop procedure if exists Sample1;;
CREATE PROCEDURE Sample1(IN lft1 INT,IN rgt1 INT,OUT emp1 VARCHAR(20))
BEGIN
SELECT p.emp into emp1 FROM personnell p WHERE p.lft>lft1 and p.rgt < rgt1 LIMIT 10;
END;;
call Sample1(1,10,@emp);;
select @emp;
错误信息
MysqL said: Documentation
#1172 - Result consisted of more than one row
注意
-----
Sample1--- procedure name;
emp -----selected field from table personnell
lft -----use to check the condition,it is also one of the field of table personnell
personnell------table name
最佳答案