I have the following stored procedure (mysql). I’m trying to expand this to show multiple results, but it currently fails when I try to expand on it. Instead of setting a product ID to loop on (which will fail if that ID doesn’t exist), I’d like to set a criteria to pull multiple entries.
DELIMITER $$
CREATE DEFINER=`tst`@`%` PROCEDURE `hmmm`(
IN fusion VARCHAR(255)
)
READS SQL DATA
BEGIN
DECLARE id_loop INT;
DECLARE id INT;
SET id_loop ='0';
SET id='147008';
REPEAT
SELECT
(
SELECT `product_id`
FROM `mydb`.`products`
WHERE `product_id` = id
) AS ProdID,
(
SELECT `Product_Other_1`
FROM `mydb`.`main`
WHERE `ProdID` = id
) AS Other
(
SELECT Count(*)
FROM `mydb`.`product_attributes`
WHERE `ProdID` = id
GROUP BY `prodID`
) AS Total_Ats;
SET id_loop = id_loop + 1;
SET id = id + 1;
UNTIL id_loop > 5
END REPEAT;
END