When I call the procedure and pass the necessary parameters to it, it returns only one record, despite the fact that there are several of them in the database.
delimiter ~ create procedure ShowRange(in MaxRange int) begin declare sId int; declare sName varchar(50); declare sType varchar(50); declare sMaxRange integer; declare countWeapon int; declare done integer default 0; declare ShowRangeCursor Cursor for select model.id,model.name,model.type,characteristics.max_range from model inner join characteristics on model.id = characteristics.model_id where characteristics.max_range = MaxRange limit 1; DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done=1; open ShowRangeCursor; while done = 0 DO fetch ShowRangeCursor into sId,sName,sType,sMaxRange; select count(model.id) into countWeapon from model inner join characteristics on model.id = characteristics.model_id where characteristics.max_range = MaxRange; if(countWeapon >0) then select sId as 'ID', sName as 'Name',sType as 'Type',sMaxRange as 'range'; else select 'В таблице не обнаружено записей' as 'Помилка'; end if; end while; close ShowRangeCursor; end~
select sId as 'ID', sName as 'Name',sType as 'Type',sMaxRange as 'range';
clearly choosing one line - Mike