I have got similar issue with my SQL query. Convert UNION selects to single select with loop in MySQL
I have "complicated" SELECT and I UNION ALL SELECTs as in example above.
My question is that maybe it can be done in LOOP?
label1: LOOP
SET p1 = p1 + 1;
IF p1 < 30 THEN
SELECT //my select
UNION ALL
ITERATE label1;
END IF;
LEAVE label1;
END LOOP label1;
Could you please tell me if it will gonna work in such way? I try to write calendar with periodic events, and I would like to iterate date by date for example 7 days and collect results from SELECTs
Thank you and Regards.