I want to delete a quantity of rows in procedure . I tried do it like this ,but I did something wrong.
BEGIN
DECLARE counter INT DEFAULT 0;
SELECT COUNT(*) INTO quantity FROM (SELECT A.idImages FROM images A WHERE A.Posts_idposts = id ) a LIMIT 1;
START TRANSACTION;
WHILE counter< quantity DO
SELECT A.idImages INTO imagesid FROM imagesA WHERE A.Posts_idposts = id LIMIT counter,1;
DELETE FROM images WHERE IdImages = imagesid;
END WHILE;
//other single deletes
COMMIT;
END
the procedure gets the "id" from the attribute
CREATE DEFINER=`root`@`localhost` PROCEDURE `usun_zgloszenie`(id INT)
the procedure lasts indefinitely