Why is the MySQL code
USE `my_database`;
CREATE TEMPORARY TABLE `my_table` (`my_column` INT);
INSERT INTO `my_table` (`my_column`) VALUES (1), (2);
WHILE EXISTS (SELECT * FROM `my_table`) DO
SET @a = (SELECT `my_column` FROM `my_table` ORDER BY `my_column` ASC LIMIT 1);
SELECT @a;
DELETE FROM `my_column` WHERE `my_column` = @a;
END WHILE;
not working? I get the error
ERROR 1064 (42000) at line 4: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHILE EXISTS (SELECT * FROM `my_table`) DO
On the other hand, the reduced code
USE `my_database`;
CREATE TEMPORARY TABLE `my_table` (`my_column` INT);
INSERT INTO `my_table` (`my_column`) VALUES (1), (2);
SET @a = (SELECT `my_column` FROM `my_table` ORDER BY `my_column` ASC LIMIT 1);
SELECT @a;
works.
The output of mysql -V
is
mysql Ver 8.0.36-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))
Sorry about the dumb question, but I have studied various WHILE-examples on the internet, and I still do not see the problem.