This is a read-only copy of the MariaDB Knowledgebase generated on 2024-11-16. For the latest, interactive version please visit https://mariadb.com/kb/.

For with in user variable error

Hello! I come to you for the following problem: in the query I need the "for" loop to go from 15 to 99 using user variables:

SET @v1 = 15; SET @v2 = 99; SET @v3 = 0;

DELIMITER //

FOR testing IN @v1..@v2 DO

SET @v3 =@v3 + 1 ; END FOR ;//

DELIMITER ;

But the server returns : "[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '@v2 DO"

If I replace the variable @ v1 with the value 15, it works perfectly, but I need it to be a user variable.

What am I doing wrong and what would be the possible solution?

Thank you very much for your attention.

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.