Am trying to fetch out a field through stored procedure and I used following query. I aimed at fetching out multiple rows, but it executes the result successfully only when a single row exists. Or else it returns an error as I mentioned below.
MySQL Query
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 personnel p
WHERE p.lft > lft1
AND p.rgt < rgt1
LIMIT 10;
END;;
CALL Sample1(1, 10, @emp);;
SELECT @emp;
Error Message
MySQL said: Documentation
#1172 - Result consisted of more than one row
NOTE
Sample1- procedure name
emp- selected field from table personnel
lft- use to check the condition, it is also one of the field of table personnel
personnel- table name