Reputation: 9858
I am trying to make simple test for while loop in stored procedure from this tutorial I faced this error
Unknown Column cnt in 'field list'
here is the sp, can somebody help?
DELIMITER $$
CREATE PROCEDURE `WhileLoopProc` ()
BEGIN
DECLARE cnt INT DEFAULT 1;
DECLARE str VARCHAR(255) DEFAULT '';
WHILE cnt < 10 DO
SET str = CONCAT(str,cnt,',');
set cnt = cnt + 1 ;
END WHILE;
SELECT str;
END $$
DELIMITER ;
Upvotes: 1
Views: 1450
Reputation: 125855
You have a no-break space character (U+00A0) immediately after your variable name in the following line:
WHILE cnt < 10 DO
^--- this is U+00A0
MySQL does not recognise such characters as whitespace, but rather as part of the variable name.
Upvotes: 2