Jak zmodyfikować tą funkcję by zwracała wszystkie znalezione wiersze. Przy więcej niż jednym rekordzie wyrzuca error subquery returns more then one row.
DROP FUNCTION IF EXISTS findByPesel;
delimiter $$
CREATE FUNCTION findByPesel(pesel varchar(11) ) returns varchar(255) deterministic
begin
declare message varchar(255) DEFAULT 'nothing';
IF pesel REGEXP '[1-9]' then
RETURN (SELECT peselid FROM readers WHERE peselid LIKE Concat('%',pesel,'%'));
else
SET message ='Not correct pesel. Write a pesel consisting of digits greater than zero';
end IF;
RETURN message;
end $$
delimiter ;
SELECT findByPesel('7') AS result;